bash

Make bash wait command fail on first error

I have a bash script that parallelise some time-consuming commands and so far it runs perfectly. I am using wait command as follows: docker pull */* & docker pull */* & docker pull */* & docker pull */* & docker pull */* & docker pull */* & docker pull */* & composer install -n & wait Now I want this…
Read more

Bash: rename beginning of filename

I have a couple of files, which look like this: 1_150901_AC7GLHANXX_P2258_101_1.fastq.gz 1_150901_AC7GLHANXX_P2258_101_2.fastq.gz 2_150901_AC7GLHANXX_P2258_101_1.fastq.gz 2_150901_AC7GLHANXX_P2258_101_2.fastq.gz … i.e., there are two files that start with 1_ and end in either _1.fastq.gz or _2.fastq.gz, and the same for two files that start with 2_. What I want to do is to cat the two files ending in _1.fastq.gz, like this: cat 1_150901_AC7GLHANXX_P2258_101_1.fastq.gz 2_150901_AC7GLHANXX_P2258_101_1.fastq.gz…
Read more

Parsing CSV file from DB

I have this DB dump file in comma separated CSV file with first line as heading/table name and rest of it are data and some has duplicate entry HOST_#_INFORMATION,HOST#,Primary Hostname,DNS Domain,IP_#_INFORMATION,Primary IP,DNS,11,abc,example.com,,10.10.10.10,10.10.10.1,12,bcd,example.com,,10.10.10.11,10.10.10.1,13,cde,example.com,,10.10.10.12,10.10.10.1,11,abc,example.com,,10.10.10.10,10.10.10.1,13,cde,example.com,,10.10.10.12,10.10.10.1 I need to print only unique columns between HOST_#_INFORMATION and IP_#_INFORMATIO. Output I am looking for is HOST#,Primary Hostname,DNS Domain11,abc,example.com12,bcd,example.com12,bcd,example.com I tried with awk gsub option but only…
Read more

How to remove the symbolic path of a command [duplicate]

This question is an exact duplicate of: exectuable path pointing to the wrong location, how do I update 2 answers I compiled and remove rkhunter into /usr/local/bin/rkhunter After that I yum install -y rkhunter but when I try to launch rkhunter I need to /usr/bin/rkhunter because it keep seeking for /usr/local/bin/rkhunter I watched into /etc/profile /etc/profile.d/ and bash_profile and see…
Read more

Looping in bash

I have a do-while loop in bash, and it runs the body once but no more. while read id; do bash ./setup_instance.sh “${id}” echo “Ran setup_instance” done < ids.txt echo “Finished of loop” The file ids.txt has two lines, one “ID” string per line. I tested this by replacing the line inside the loop with echo “ID: ${id}” and the…
Read more

Inconsistency in diff results for equivalent changes

Consider the following files and diff results: a1.txt a b My name is Ian a2.txt a a b My name is John Running diff –side-by-side –suppress-common-lines a1.txt a2.txt produces: > a My name is Ian | My name is John Which correctly states that a was added in a2.txt and My name is Ian changed to My name is John….
Read more

How would I create an SFTP connection if my application framework does not contain an API for it?

I am trying to connect to an SFTP server with my AIR application. It doesn’t matter that it’s an AIR application except that I haven’t found any libraries or AIR API methods for it. My first thought is to find a library in another language and rewrite it in ActionScript. I’d rather not do that and my lack of experience…
Read more

How to list files and match first line in bash script?

I would like to check for (only) python files for those which do not have the #!/usr/bin/env python in the first line. So, I write a bash script that does the following: #!/bin/bash #list all of python files for file in `find . -name “*.py”` do if [ `head -1 $file` != “#!/usr/bin/env python”] then; echo “no match in file…
Read more