This question already has an answer here:

I have a txt files with all the file names I need to analyze. I have this file (inputFile.txt) :

/path/file1a  path/file1b 
/path/file2a  path/file2b

i have a code which needs two two input files in order to run.

./Analyzethis /path/file1a /path/file1b

i am trying to create a bash loop to go through my txt files, read through each row and run my code.

I had

IFS=$'\n'; for FILE1 in `cat inputFile.txt`; do ./Analyzethis $FILE1; done

but, it doesnt work. How can i loop through each row and use the columns with the bash loop?

marked as duplicate by ilkkachu, user34720, Mr Shunz, Haxiel, msp9011 Mar 21 at 12:28

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


This is a bash FAQ: How can I read a file (data stream, variable) line-by-line (and/or field-by-field)?

while read -r first second; do 
    ./Analyzethis "$first" "$second"
done < inputFile.txt

make sure you quote your variables

While you're reading that FAQ page, make sure you read Don't try to use "for"

Not the answer you're looking for? Browse other questions tagged or ask your own question.