0

I'm new in bash linux coding. Basically I would like to do a loop using a text file with two columns.

For a single column file I use this type of code:

for element in `cat /path/file.txt | tr -d '\r'`
do
operation on element
done

I would like to use the two elements of each line as argument for a function. So it would be like:

file.txt:

Column A Column B
a c
b d

And the using in the same line of code the first row of column A and B, then the second row and go on...

I don't know if it is possible to use indexes to specify the row and column that I want for each iteration.

Giordano
  • 81
  • 5

1 Answers1

1

It looks like you want:

tr -d '\r' < /path/file.txt | 
while read a b; do
  operate "$a" "$b"
done
William Pursell
  • 204,365
  • 48
  • 270
  • 300