yelbow
asked on
csh script read multiple values from each line in text file
Hi,
I have a text file with entries as follows:
In a unix script (which is csh and can't be changed), I want to read the contents of each file line by line and attribute each "column" of data to a separate variable so that further processing can be done on it before then reading the second line
In an ideal world this would be something line
but that doesn't work as it sees each "column" as a "line".
Googling shows plenty of suggestions for when other unix shells, but I'm looking for a way to do this in csh.
Any help much appreciated.
I have a text file with entries as follows:
00001 99999 testlinea
00002 99998 testlineb
00002 99997 testlineb
00002 99998 testlineb
00002 99997 testlineb
In a unix script (which is csh and can't be changed), I want to read the contents of each file line by line and attribute each "column" of data to a separate variable so that further processing can be done on it before then reading the second line
In an ideal world this would be something line
foreach $line (`cat filea`)
set valuea= `echo $line | awk '{print1}'`
set valueb= `echo $line | awk '{print2}'`
set valuec= `echo $line | awk '{print3}'`
[do other things before moving on to the next line in filea]
end
but that doesn't work as it sees each "column" as a "line".
Googling shows plenty of suggestions for when other unix shells, but I'm looking for a way to do this in csh.
Any help much appreciated.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER