Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!pitt!darth!investor.pgh.pa.us!rbp From: rbp@investor.pgh.pa.us (Bob Peirce #305) Newsgroups: comp.unix.shell Subject: Re: Problem using multiple 'head' commands in shell script Keywords: head shell buffering split(1) Message-ID: <1991Feb4.122652.10724@investor.pgh.pa.us> Date: 4 Feb 91 12:26:52 GMT References: <1671@abekrd.UUCP> Reply-To: rbp@investor.pgh.pa.us (Bob Peirce #305) Organization: Cookson, Peirce & Co., Pittsburgh, PA Lines: 26 In article <1671@abekrd.UUCP> garyb@abekrd.UUCP (Gary Bartlett) writes: >Can someone explain to me what is happening with the following Bourne shell >script and more importantly how I can get around it: > > cat file | ( > head -200 > echo "Line 201 follows" > head -200 > echo "Line 401 follows" > cat > ) > >I am trying to use 'head' as a quick way to split up an input stream. I >originally used 'read' and an 'expr' counter but this was too slow. > >This script loses lines after each 'head'. eg if file contained a stream of >numbers, the output would be missing lots of numbers! > Why not use cat file | split -200 commands to process x?? files -- Bob Peirce, Pittsburgh, PA 412-471-5320 ...!uunet!pitt!investor!rbp rbp@investor.pgh.pa.us