Introducing UNIX and Linux |
Introduction to shellsOverview |
Answer to chapter 7 question 7You need to keep a count of the number of the line, which can be
incremented with the aid of LINENUMBER=1 # To store the line number while read LINE # 'read' returns false at end do # of input # Print the line number and the line printf "%6d %s\n" $LINENUMBER $LINE # Add one to the line number LINENUMBER=$( echo "$LINENUMBER + 1" | bc ) done |
Copyright © 2002 Mike Joy, Stephen Jarvis and Michael Luck