Unix Shell Scripting Question

Discussion in 'OT Technology' started by MaxMouse, Jul 24, 2005.

  1. MaxMouse

    MaxMouse New Member

    Joined:
    Jun 7, 2003
    Messages:
    197
    Likes Received:
    0
    Location:
    toronto
    I'm trying to write a Bourne shell script that simulates the 'wc' command without using 'wc' itself or awk.

    This is what I have as of now:
    Code:
    lineCount=0
       while read line <&3
       do
         lineCount=`expr $lineCount + 1`
         echo $lineCount
       done
    
    My question is, how do I count the individual words on each line? I know I need a loop nested inside my while loop, but I don't know how to actual break down each line to read it's individual words.
     

Share This Page