Is there a way to print a document from the nano text editor, i.e. send it to a printer to be physically printed out? I see that vim and emacs have this feature but I like the simplicity of nano. If not, is there a way to print the document with a linux command?


I can see no mention of a print command in nano's manual and it would surprise me to find one. The traditional method of printing in *nix systems is the lpr command:

$ lpr foo.txt

From man lpr:

   lpr  submits  files  for  printing. Files named on the command line are
   sent to the named printer (or the default destination if no destination
   is  specified).  If  no files are listed on the command-line, lpr reads
   the print file from the standard input.

You can also use a slightly more modern equivalent, enscript:

   Enscript converts text files to PostScript  or  to  other  output  lan‐
   guages.   Enscript  can spool the generated output directly to a speci‐
   fied printer or leave it to a file.   If  no  input  files  are  given,
   enscript  processes the standard input stdin.  Enscript can be extended
   to handle different output media and it has many options which  can  be
   used to customize the printouts.
| improve this answer | |
  • Would this work for files with non .txt extensions? lpr will only print plaintext files but I need to print out source code for files with extensions like .cpp, but the contents are basically plaintext, aren't they? Thanks. – Neal Sep 29 '13 at 14:39
  • @Neal the *nix world does not use extensions not determine file type (some graphical apps do but those are another matter). lpr will treat its input as text and print it accordingly. – terdon Sep 29 '13 at 14:52

I needed to do the same thing. My solution using the command line:

  • Type less filename >> filename.txt.
  • Then I typed lp filename.txt and it printed!
| improve this answer | |
  • This command isn't actually using nano like the OP asked for, but it is a neat solution. Could you perhaps go into a little more detail on what lp does? – Burgi Dec 21 '17 at 8:57

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.