Link to home
Start Free TrialLog in
Avatar of xewoox
xewoox

asked on

How to parse file in shell script?

Hi,

I have a file with 3 columns of data. I would like to write a shell script file to parse the data. How to do that?

#!/bin/sh

cat in_file | while read LINE
do
   echo "$LINE"
   # here I got the line from the file

   # now I want to extract data from column1, column2 and column3

   # I tried the following but it doesn't work
   column1=`awk '{print $1}' $LINE`
   # as it complain $LINE is not a file.
 
   # Any idea? What command should I use?
 
  # do something with the data....

done
SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany 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
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
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 xewoox
xewoox

ASKER

Thank you