I am very new to shell programming.
I have a file named quaternary_splitted.csv on macOS.
Every line has 4 words. I want to take every word from each line and assign it to a variable. Please suggest some kind of awk command in for loop
The value of each of those 4 variable I want to use further in my shell program.
Thanks for the help.
Few of the lines from the file:
Ta Cr Mo W
Nb Cr Mo W
Nb Ta Mo W
Nb Ta Cr W
Nb Ta Cr Mo
Best Answer
You can do this with a
while read
loop like so:This will read through each line of
quaternary_splitted.csv
and set the first column tocol1
, second column tocol2
, etc.The
trash
parameter is used to catch anything that may be in your file and unwanted. Say you had a line:Nb Ta Cr W what is this doing here?
. Without trash you would get: