Link to home
Start Free TrialLog in
Avatar of deep_well
deep_well

asked on

printing a file

How do i print a C file in unix that has line numbers in it?
i want the answer right away... i think its very easy one...
Avatar of Kim Ryan
Kim Ryan
Flag of Australia image

You should be able to print any text file on Unix to the default printer using:

   lp file_name

Do you want the file numbers to be added by the print command, or are they alredy in your file?
ASKER CERTIFIED SOLUTION
Avatar of rbr
rbr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of indego
indego

I looked at this on my system and it is nearly right but not quite. There may have been a typo. Also this adds nicer formatting.

cat filename | awk '{print NR ": " $0}' | lp
Avatar of deep_well

ASKER

good one rbr keep it up.
Using HP-UX with HP printers there is not normally a problem
printing files with line numbers, i.e. lp filename works fine.   However,  with QMS printers I've seen them get confused in that the printer thinks the file is HPGL, but it's not and the result is no print or an error printout.  In this case, use:

lp -oPCL filename

This tells the printer to use the HP PCL language which should handle any ascii files.