Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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!!

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.txtthen do both with:
tail -100 file.txt | lpr

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!

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.

![]() |
![]() |
![]() |

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