Computing.Net > Forums > Unix > Printing last few pages (or lines) of a

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Printing last few pages (or lines) of a

Reply to Message Icon

Name: kbrooks
Date: June 15, 2001 at 06:56:49 Pacific
Comment:

I need to be able to print the last few pages (or lines) of a very large file. Can anyone help me out? I know how to print the whole thing,and I know how to VIEW the last few lines. Thank you!!



Sponsored Link
Ads by Google

Response Number 1
Name: Don Arnett
Date: June 15, 2001 at 08:16:18 Pacific
Reply:

Just pipe what you view to the print command.

If you view with:

tail -100 file.txt

and print with:

lpr file.txt


Another option would be to send the tail results to a file and then print that:

tail -100 file.txt >tmp.txt
lpr tmp.txt

then do both with:

tail -100 file.txt | lpr


0

Response Number 2
Name: gmf0820
Date: June 15, 2001 at 09:45:42 Pacific
Reply:

Not to be dense, but can you clarify that for me? I'm printing to a printer called comprm, and I want the last, say, 500 lines of a file called PA8513.R01 So would I enter:
lpr comprm tail -500 PA8513.R01

?

Thank you!


0

Response Number 3
Name: Don Arnett
Date: June 15, 2001 at 13:26:29 Pacific
Reply:

I expect what you want is:

tail -500 PA8513.R01 | lpr -d comprm

Put the tail command first, then a pipe symbol ('|'), then the print command.

To understand how this works, you need to understand the concepts of 'stdin' (standard input) and 'stdout' (standard output).

What we've done above is connected the standard output from the 'tail' command to the 'standard input' of the 'lpr' command. In other words, we've redirected the output from 'tail' (which normally goes to the screen) so that it is read by the input stream of 'lpr'.

Trying to explain 'stdin' and 'stdout' is not easily done in a few paragraphs, so I'll leave you to find a text book or something if you don't know what that is.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Printing last few pages (or lines) of a

Delete first line of a file www.computing.net/answers/unix/delete-first-line-of-a-file/7594.html

Last line of a file www.computing.net/answers/unix/last-line-of-a-file/5489.html

Append to last line of file www.computing.net/answers/unix/append-to-last-line-of-file/5212.html