Skip to content

Tag: bash

Using unbuffered pipe as “dummy” file output

I’ve been dealing with a weird issue that I can’t find a way to solve. My situation is as follows. I have an application in python called “app1”, that requires a file for outputting the results of it’s execution. I have a secondary application, called “app2”; a binary…

$SHLVL does not increase in ( echo $SHLVL)

I am learning shell scripts and stuck at this little experimental shell scripts: Without doubt, $A in line 3 and line 4 are different from each other, which can be explained that it is because the parent process cannot read variables created in the child process, that is, the subshell. However, the $SHLVL in …

Change some field separators in awk

I have a input file 1.txt and I want an output file: out.txt I want to replace the first two ‘:’ in 1.txt with ‘||o||’, but with the script I am using But it is not giving the expected output. Any help would be highly appreciated. Answer Following sed may also help you in same. Explana…

set length of captured group

I would like to format the log of my server to be readable easily when I do a “tail -f”. My log look like : I would like to obtain : Where ‘_’ is a white space. For now I use : And I get : It is possible to set the length of captured group 1 2 3 ?

Matching files using awk in linux

I have 2 files: 1.txt: 2.txt: I want 2 files as output: One is result.txt which contains lines from 2.txt whose match is in 1.txt and another is left.txt which contains lines from 1.txt whose match is not in 2.txt Expected output of both files is below: result.txt left.txt I tried 1-2 approaches with awk but …

Merge two files using awk in linux

I have a 1.txt file: A 2.txt file: FS for 1.txt is “||o||” and for 2.txt is “:” I want to merge two files in a single file result.txt based on the condition that the 3rd column of 1.txt must match with 1st column of 2.txt file and should be replaced by the 2nd column of 2.txt file. The…

Bash Script Unstable Result

I have bash script and I put in the crontab. It runs every 10 minutes. When I run it manually, it gives perfect results. It creates “.tmp” files and these “.tmp” files are not empty, but Crontab results are not as I expected. it only creates “.tmp” files. Contents of &#8220…