[HPADM] SUMMARY processing stdio with multiple commands

From: Julius Szelagiewicz (julius@turtle.com)
Date: Mon Jun 17 2002 - 10:02:53 EDT


Dear Admins,
        i got 2 excellent answers from James Sohr and Lutz Sommerfeld,
i'll quote Lutz's as the summary.
the original problem:
        I need to process a file that comes to a script through a pipe. i
need to do things to the lines 10+ based on content of lines 1 to 9. the
file may be rather large and i'd like to avoid creating temporary file. is
there a way to grab first 9 lines with one command and pass the rest to
another?

> -----
> #!/usr/bin/ksh
>
> head=""
> typeset -i num
> num=0
>
> echo "Lines 1-9 of stream:"
>
> while [ $num -le 9 ]
> do
> read line
> echo $line
> head="$head\n$line"
> num=$num+1
> done
>
> echo "\nThe whole file:"
>
> echo $head | tail +2 # Get rid of "\n" in first line
> while read line
> do
> echo $line
> done
>
> ---------

--
             ---> Please post QUESTIONS and SUMMARIES only!! <---
        To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl
       Name: hpux-admin@dutchworks.nl     Owner: owner-hpux-admin@dutchworks.nl
 
 Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse only)
            http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse & search)


This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 11:02:14 EDT