Skip to content
Advertisement

Tag: shell

Shell append redirection replaces existing text?

For our school assignment, we have to implement input/output redirection. I managed to get the input and output redirection work, but I am facing an issue with append redirection. I am using testfile.txt: When the user types ls >> testfile.txt, I expect the output from ls to be added to the testfile. At this moment, the test lines get replaced

Are there any solutions to this command(shell code) problem

I have some shell codes looks like: but, get an error “-bash: syntax error near unexpected token `(‘” which i can’t fix it. I do know the pipeline command can also do it well. likes but actually I wish to do something in the loops like change the global value and the pipeline didn’t work. Answer The correct syntax for

Running bash script on multiple shells

So I was trying to create a script on bash shell, I came to know that the script doesn’t run on ksh or dash shells. So my question is how you make a script to run on all 3 (bash, dash & ksh) shells. Answer In order to write a script that is guaranteed to be portable between the various

replace in text with a var with some new lines

I have a var $MY_VAR which contains some new lines: And a file my_file.txt with a value that has to be replaced: I try to replace it using: That results into the following error: Answer I finally found a totally different solution by removing the value to replace and split my file into two parts: my_file_part1.txt and my_file_part2.txt which are

shell script to change directory to the tail result path

I’m using Tail to an error happen on the log lines like: and this gives results like: So what I do manually is to change the path using cd: Is there any script to change directory automatically? As I run another manual script to change file names for the files contained in /003217899/, those like /003217899/ are happening many times

Looking to remove a set of characters from a .txt file

I am looking for a way to remove the content from one .txt file based on the other. For example, I have a file.txt with 2000 character that are random and not sorted. I have another file importantfile.txt with 2016 characters that have the same characters that file.txt has as well as 16 other characters randomly placed in. Is there

Advertisement