[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: using tail in a pipe and script



On Sat, Dec 29, 2001 at 09:56:13AM -0600, Lance Hoffmeyer wrote:
| I am trying to write a script and I need to remove the top 3 lines of a
| file.  I thought tail would be the tool for the job.
| 
| The script is:
| 
| enscript -1 -r -M Letter -p outputfile $1
| 
| I need tail to take off the top 3 lines of $1
| 
| 
| enscript -1 -r -M Letter -p outputfile `tail +3 $1`
| 
| does not work.

Right.  enscript is expecting a filename, but the output of tail does
not create a filename.

Instead try :

tail +3 $1 | enscript -1 -r -M Letter -p outputfile

The difference is that tail writes some data to it's stdout.  The pipe
symbol redirects tail's stdout from the console to instead go to
enscript's stdin.  Since you didn't specify a filename to enscript it
looks to stdin for data, which is tail's output.

-D

-- 

Consider what God has done:
    Who can straighten what He has made crooked?
        Ecclesiastes 7:13



Reply to: