Link to home
Start Free TrialLog in
Avatar of yelbow
yelbow

asked on

csh script read multiple values from each line in text file

Hi,

I have a text file with entries as follows:

00001 99999 testlinea
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

Open in new window


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
Avatar of serialband
serialband
Flag of Ukraine image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yelbow
yelbow

ASKER

Thanks!  Both seem valid, but went with Tintins solution - thanks for your time, and your sympathy ;)