0

Where can I find more information about the command(?) print since I don't receive a result when I input man print? For example, in the zsh I can do the following:

$ print "Hello, world\!"
Hello, world!

I've seen print -P foo and print -n bar used among other flags and have no idea what they mean nor do I know where to look for further information. So we have two questions really:

  1. Where does print come from and where can I find documentation for it?
  2. Where does one find documentation for similar items that are not to be found in the man pages?

NOTE: For clarification, I'm not trying to print a sheet of paper. I am also aware of printf, which allows for formatted output and has a man page.

  • 2
    What is print? – Eddy_Em Jun 20 '13 at 4:44
  • 3
    Downvoters: while the question may not be a model of detail and backegound research, it is IMHO a valid and valuable entry-level question. The fact that it assumes things are simple when they are not is hardly the asker's fault. Unix printing should be at least as simple as on other platforms, in an ideal world. – tripleee Jun 20 '13 at 12:48
  • 2
    @tripleee It probably got downvoted because nobody knows which "print" they're referring to and there's been no attempt at clarifying it – Michael Mrozek Jun 20 '13 at 14:15
  • 1
    @MichaelMrozek (or rather @downvoters) As I write, vrtcl1dvoshun hasn't been back to the site yet, so he hasn't had an opportunity to clarify. I think that printing is meant in the layman sense. If it wasn't clear, the question should be closed as NaRQ, but there isn't a single close vote. – Gilles 'SO- stop being evil' Jun 20 '13 at 18:17
  • 1
    So you want the documentation of the shell builtin after all? Then your question would be a duplicate of missing man pages of some commands. Given that there are now two detailed answers about printing in the layman sense, I think the best course of action would be to edit this question to be about printing, but I'll edit something about print in my answer. – Gilles 'SO- stop being evil' Jun 21 '13 at 9:46
6

In zsh, at the prompt, type print, and then Alt-H.

If it gives you the man page for the print system command instead of the print builtin, you may want to follow the instructions given under Accessing On-Line Help at:

info zsh Utilities

For zsh documentation, I prefer to use info in general. The zsh documentation is properly indexed and it's very easy to find documentation using info.

For instance to find the documentation for print, type info zsh, and within info, type i to bring up the index prompt and type print (you can throw in a couple of Tab to get a completion list). Or just run

info zsh print

To open the zsh info book and jump directly to the print index entry.

2

Documentation for the print command

man print only gives you information about a command called print. Unfortunately, the command to print a file is not called print.

Ksh and zsh have a built-in command print. Like all built-ins, they are documented in the manual for the shell (man zshbuiltins or the very long man zshall for zsh). You can tell that a command is built-in with type:

$ type print
print is a shell builtin

apropos print would show a list of commands whose description contains the word “print”; what you're looking for is in there, but buried inside a lot of other commands where “print” is used in the sense of “display text in the terminal”.

On Debian and derived distributions including Ubuntu, there is a command called print, which has a man page. It is part of the mime-support package, which also provides commands see, edit and compose. This package uses /etc/mime.types to determine the file's MIME type from the file name extension and /etc/mailcap and ~/.mailcap to determine which program to use.

On most Linux distributions, xdg-open plays a similar role to Debian's edit, but there is no analog for print.

A primer on printing from the command line

Most unix installations these days use CUPS for printing. This system originated on Mac OS X but is now dominant on Linux and present on other unix variants as well. CUPS is easiest to configure through its web interface at http://localhost:631/.

If the printer is already configured and you want to print, depending on your system, the command is either lp or lpr. The simplest form of the command is lp myfile.ps or lpr myfile.pdf; depending on which printing system your computer uses, these commands may support many options. Check the man page on your system for details. If you need to specify a printer name, it's lp -d printername myfile.ps or lpr -Pprintername myfile.ps.

The traditional file format for printing is PostScript. Nowadays, most printing systems support PDF out of the box as well, and possibly other formats. I don't think there's an easy way to find out what input formats are supported, so I recommend converting your file to PS or PDF before printing (you'll have more control over layout options that way anyway).

You can see what files are currently being printed with the command lpstat or lpq. This lets you know when your file has finished printing (or rather when it's been fully transmitted to the printer). This also tells gives you the job ID for your print job, which you can use to cancel the job with lprm or cancel. You can also see a list of available printers with lpstat -a or lpq -a.

If your system is using CUPS, another useful command is lpoptions. The command lpoptions -l lists printer options that you can use on the lp or lpr command lines; for example, with many duplex printers, lp -o Duplex=DuplexNoTumble prints double-sided.

1

You are probably looking for printf. Since printf is a build in of your shell, you should look in the shell's man page, probably with man bash and search for printf

  • Wonder if he wanted printf or print as in printing 8-). – slm Jun 20 '13 at 5:18
  • @slm Or just should install mailcap. On my system man print gives me a man page. – Anthon Jun 20 '13 at 5:20
  • What man page is it? Formatted printing or something else? – slm Jun 20 '13 at 5:21
  • mailcap on fedora doesn't include this man page. – slm Jun 20 '13 at 5:25
  • It is installed with package mime-support on Ubuntu (12.04). NAME run-mailcap, view, see, edit, compose, print - execute programs via entries in the mailcap file. Never seen it before, therefor my first thought was the OP meant printf – Anthon Jun 20 '13 at 5:27
1

If you're asking about how to print from the command line the command you're looking for is usually lpr or lp. These are frontend tools for printing files from the command line.

NOTE: You can search the man pages using -k to search for keywords. If you'd done man -k print you would've found these pages.

To see what printers are available you can use lpstat -a, for example:

$ lpstat -a
brfax accepting requests since Wed 19 Jun 2013 06:20:02 PM EDT
Brother-MFC-4800 accepting requests since Wed 05 Jun 2013 01:35:48 PM EDT
Brother-MFC-J825DW accepting requests since Mon 17 Dec 2012 01:54:12 PM EST
mfc-8480dn accepting requests since Wed 19 Jun 2013 06:19:59 PM EDT
s820 accepting requests since Wed 19 Jun 2013 06:20:01 PM EDT
s820-scully accepting requests since Wed 19 Jun 2013 06:20:02 PM EDT
Stylus-NX300 accepting requests since Fri 08 Mar 2013 03:13:58 PM EST

To print to one of these printers I generally use the lp command like so:

$ lp -d mfc-8480dn sample.txt
request id is mfc-8480dn-454 (1 file(s))

To see what's in your print queue:

$ lpq -a
Rank    Owner   Job     File(s)                         Total Size
1st     saml    453     (stdin)                         0 bytes
active  saml    454     sample.txt                   1024 bytes

To remove a job from the print queue:

$ lprm 453

The print queue is now empty:

$ lpq -a
no entries
  • 1
    Good answer, but on a modern Linux system, I would expect the user to look for something more like CUPS, which complicates matters even further. – tripleee Jun 20 '13 at 12:12
  • 1
    @tripleee - these commands are just frontends. My entire backend is using CUPS. lpr is in fact part of the cups package. rpm -qf /usr/bin/lpr shows it's package as cups-1.4.8-5.fc14.x86_64. – slm Jun 20 '13 at 12:19
  • Yeah, but it's a bit of a stretch to try to understand the printing system based on the documentation for a legacy front-end. – tripleee Jun 20 '13 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.