By the previous description, I believe your commands and features of Linux have a basic understanding of this section explains how to print files and send messages.
If you want to print a text file, it is best to handle it in advance, including the adjustment of margins, set the row height, set the title, etc., so print out documents more attractive and easy to read. Of course, the process also can not print, but may be more ugly.
Most Linux comes with two powerful nroff and troff text formatting tools, but relatively old, very few people use, interested readers can learn on their own, no in-depth explanation of this tutorial.
pr command to convert the text file into a format suitable for printing, it can split large files into multiple pages to print, and add a title for each page.
pr command syntax is as follows:
pr option (s) filename (s)
pr command simply changing the file display style on the screen and print output style, and does not change the file itself. The following table several options pr command:
-k print into several columns, the default is 1.
-d double spaced (not all versions of pr are valid).
-h "header" to set the title of each page.
-t Do not print the title and the top and bottom margins.
-l PAGE_LENGTH how many lines per page. The default is a total of 66 lines per page, text, accounting for 56 rows.
-o MARGIN number of spaces to indent each row.
-w PAGE_WIDTH multi-column output, set the page width, the default is 72 characters.
For example, food that contains a lot of file names food, using pr command is divided into two print, and set the page titled "Restaurants".
First, view the file contents:
$ Cat food
Isle of Java
Big Apple Deli
Sushi and Sashimi
Tio Pepe's Peppers
Then use the Print command pr:
$ Pr -2 -h "Restaurants" food
Nov 7 9:58 1997 Restaurants Page 1
Sweet Tooth Isle of Java
Bangkok Wok Big Apple Deli
Mandalay Sushi and Sashimi
Afghani Cuisine Tio Pepe's Peppers
lp and lpr command
lp and lpr command to transfer the file to the printer for printing. Pr command using the file format, ready to use these two commands to print.
Printers are generally set by the system administrator, the following example uses the default printer to print food item:
$ Lp food
request id is laserp-525 (1 file)
Successful execution of the command will return a representation of the print job ID, the ID can be canceled by print or view the print status.
If you want to print multiple copies of a file, you can use the lp -nNum option or options -Num lpr command. Num is a number that can be freely set.
If the system is connected to more than one printer, you can use the lp command -dprinter option, or the option -Pprinter lpr command to select a printer. printer printer name.
lpstat and lpq command
lpstat command to see printer queue buffer (the number of documents waiting to be printed), including the task ID, owner, file size, request time and the status of requests.
Tip: Wait to print files will be placed in the printer's buffer queue.
For example, use lpstat -o command to view all the printer files waiting to print, including your own:
$ Lpstat -o
laserp-573 john 128865 Nov 7 11:27 on laserp
laserp-574 grace 82744 Nov 7 11:28
laserp-575 john 23347 Nov 7 11:35
lpstat -o command output queue file in accordance with the print order.
Information with lpstat -o lpq command displays slightly different:
laserp is ready and printing
Rank Owner Job Files Total Size
active john 573 report.ps 128865 bytes
1st grace 574 ch03.ps ch04.ps 82744 bytes
2nd john 575 standard input 23347 bytes
The first line printer status. If the printer is out of paper or is not available, additional information will be output.
cancel and lprm command
lprm and cancel print requests are used to terminate the lp and lpr. Using these two commands, you need to specify the ID (returned by lp or lpq) or the name of the printer.
For example, cancel a print request by ID:
$ Cancel laserp-575
request "laserp-575" cancelled
If you want to cancel the file is printing, you can not specify the ID, you can simply specify the name of the printer:
$ Cancel laserp
request "laserp-573" cancelled
lprm command to remove the current user is waiting to print the file, use the job number as an argument to cancel the specified file, use the dash (-) as an argument to cancel all files.
For example, to cancel the print job number 575:
$ Lprm 575
lprm will return the file name to be canceled.
You can use the mail command to send and receive mail, the following syntax:
$ Mail [-s subject] [-c cc-addr] [-b bcc-addr] to-addr
The meaning of each option are as follows:
Option Description -s message headers. -c To send user, multiple users with a comma (,) separated. -b need to send confidential (BCC) users, multiple users with a comma (,) separated.
For example, send a message to email@example.com:
$ Mail -s "Test Message" firstname.lastname@example.org
this is Linux tutorial and url is http://see.xidian.edu.cn/cpp/linux/.
The first line is the command input, -s indicate the subject of the message behind the email@example.com is the recipient of the message, enter the command line after the carriage return, will enter the body of the message write, you can enter any text , such as the above two lines. Enter the complete body of the message, you need to press CTRL + D input end, then you will be prompted to enter the Cc address, e-mail CC address, there is no direct Enter to complete the message sent.
You can also redirection operator
$ Mail -s "Report 05/06/07" firstname.lastname@example.org
Through the above command, you can put the contents of the file demol.txt as the content of the message to the email@example.com.
Receive messages without any parameters: