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…
Tag: bash
Doing git clone with bash script, could not read Password for repository
I’m trying to deploy Amazon EC2 instance through CloudFormation and I’m trying to clone a repository with a bash script with cfn-init. However, when I deploy the EC2 instance, I can see from cloud-init-output.log that the git clone fails, and this is the error: How can I input the password with th…
$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…
bash / cmp: compare two consecutive jpg. files with same size of a long list
I’m trying to apply the cmp command to a number of consecutive jpg files with same size but different name, in order to make sure they are the indeed same. Since there are almost 4000 files, I would like to create a for loop through them with cmp and produce a final output with the list of actual same f…
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…
Inconsistent behavior when replacing substring with tilde “~” in a BASH parameter expansion
I came across some strangely inconsistent behavior in BASH parameter expansions across a few different servers, while trying to write a quick function. On some versions of BASH, to use a tilde in a substring replacement, the tilde must be escaped, or it will be re-expanded to the home directory: while on othe…
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 “…