Skip to content

Reading a file, word by word

September 2, 2011
#!/bin/sh
ln=1
#Reading from config file
while [ ! -z "$ln" ] 
do
    read ln
    word1=`echo $ln | awk '{print $1}'`
    word2=`echo $ln | awk '{print $2}'`
    word3=`echo $ln | awk '{print $3}'`    

echo "word1 =  $word1 ,word2 = $word2, word3 = $word3"
done < ./config
Advertisements

From → Linux

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: