The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 07-02-2009
palsevlohit_123 palsevlohit_123 is offline
Registered User
  
 

Join Date: Aug 2008
Location: India-Chennai
Posts: 120
try out this..

Code:
NoOfWords=0
while read LINE
do
        NoOfWords=`echo $LINE|wc -w|awk '{print $1}'`
        #echo "NoOfWords : [$LINE][$NoOfWords]"
        if [ "$NoOfWords" -eq "1" ]
        then
                echo "$OutString " " $LINE"
        elif [ "$NoOfWords" -eq "10" ]
        then
                OutString=`echo $LINE|awk '{printf "%s %s", $10,$4}'`
        elif [ "$NoOfWords" -eq "11" ]
        then
                OutString=`echo $LINE|awk '{printf "%s %s %s", $11,$4,$5}'`
        fi
done < Filename

Note : instead of Filename, you have to give the input filename.