Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


printing a file

Posted on 1999-06-22
Medium Priority
Last Modified: 2013-12-06
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...
Question by:deep_well
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 19

Expert Comment

by:Kim Ryan
ID: 2011143
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?
LVL 10

Accepted Solution

rbr earned 100 total points
ID: 2011144
cat filename | awk ´{print FNR $0}´ | lp


Expert Comment

ID: 2011145
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

Author Comment

ID: 2011146
good one rbr keep it up.

Expert Comment

ID: 2011147
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.

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses

661 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question