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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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