Wicked Cool Shell Scripts
Wicked Cool Shell Scripts :: shell script 033-toolong.sh

Shell Script 033-toolong.sh

#!/bin/sh
# toolong - only feed the fmt command those lines in the input stream 
#    that are longer than the specified length

width=72

if [ ! -r "$1" ] ; then
  echo "Usage: $0 filename" >&2; exit 1
fi

while read input
  do
     if [ ${#input} -gt $width ] ; then
       echo "$input" | fmt 
     else
       echo "$input"
     fi
  done < $1

exit 0


Explore The Book!
[book cover]
Table of Contents
Read Some Scripts!
Shell Script Library
Book Errata
All The Links
Read the Reviews
Talk About It
Author Bio
Buy The Book!



Other books by author Dave Taylor
Learning Unix for Mac OS X (O'Reilly & Associates)
Solaris 9 for Dummies (Wiley)
Teach Yourself Unix in 24 Hours (Sams/Macmillan)
Teach Yourself Unix System Administration in 24 Hours (Sams/Macmillan)
Creating Cool HTML 4 Web Pages (Wiley)
Ten Quick Steps to Learning Mac OS X Unix (ebook!)