Basic utilities: print, email in Unix
By this chapter, you have a few basic insights about Unix systems and some of its basic commands. This chapter will briefly discuss some of the basic but important utilities of Unix utilities that you will use in your daily activities.
Print files in Unix / Linux
Before you print a file on a Unix system, you may want to reformat it to customize the margins, highlight some words, and so on. Most files can be printed without reformatting, but such raw prints often don't look very good.
Many versions of Unix include two very handy text formats: nroff and troff . They are not covered in this chapter, but you can find out their utility through the network.
Pr command in Unix / Linux
The pr command reflects the file format process on the terminal screen or for a printer. For example, if you have a list of long names for a file, you can format it on the screen into two or more columns.
Here is the command syntax pr :
pr option ( s ) filename ( s )
The pr command changes the format of the file only on the screen or on the printout, it does not edit the original file. The following table lists some of the pr command options:
Function Description -k Create k output columns. -d Dual space at the output (not on all pr versions). -h "header" Make the new item become a report title. -t Remove margins when printing headings and upper / lower margins. -l PAGE_LENGTH Set the page length to PAGE_LENGTH (66) line. The default number of words for lines is 56. -o MARGIN Print each line with a margin of 0. 0. -w PAGE_WIDTH Set the width to PAGE_WIDTH (72) characters for multi-column output only.Before using pr , here are the contents of a sample file: food.
$ cat food Sweet Tooth Bangkok Wok Mandalay Afghani Cuisine Isle of Java Big Apple Deli Sushi and Sashimi Tio Pepe 's Peppers .. $
Now we use the pr command to create a 2-column report with the title Restaurents:
$ pr - 2 - h "Restaurants" food Nov 7 9 : 58 1997 Restaurants Page 1 Sweet Tooth Isle of Java Bangkok Wok Big Apple Mandalay Sushi and Sashimi Afghani Cuisine Tio Pepe 's Peppers .. $
Ip and Ipr commands in Unix / Linux
The command Ip or Ipr prints a file on paper from the display. Once you have formatted the file using the pr command and are ready to print, you can use any of these commands to print your file on the printer that is connected to your computer.
The system manager may have set up the default printer at your site. To print a file named food on the default printer, use the command lp or lpr as in the following example:
$ lp food request id is laserp - 525 ( 1 file ) $
The Ip command indicates an ID that you can use to stop a print job or check its status.
If you use the Ip command, you can use the function -n Num to print the number of copies as Num . Along with the Ipr command, you can use the -Num option to do the same.
If there are multiple printers connected to your computer, then you can choose a printer by using the –dprinter option with the Ip command and using the -P printer option with the Ipr command for the same purpose. . Here, the printer is the printer name.
Ipstat and Ipq commands in Unix / Linux
The Ipstat command shows what is in the printer row: Request ID, file size, when jobs are sent for printing purposes, and status of requests.
Use Ipstat -o if you want to see all the output requirements, not just your own requirements. The requirements are presented in the order they are printed:
$ lpstat - 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 $
The Ipq command provides information slightly different from the Ipstat -o command:
$ lpq laserp is ready and printing Job Manager Rank Rank Total Size active jinh 573 report . ps 128865 bytes 1st grace 574 ch03 . ps ch04 . ps 82744 bytes 2nd john 575 standard input 23347 bytes $
Here the first line shows the printer status. If the printer is not working or running out of paper, you can observe other information on the first line.
Cancel and Iprm commands in Unix / Linux
The cancel terminates the print request from the Ip command. The Iprm command ends the Ipr requests. You can specify either the request ID (displayed by the Ip or Ipq command) or the name of the printer.
$ cancel laserp - 575 request "laserp-575" canceled $
To stop the current print request, regardless of its ID, simply press cancel and the printer name:
$ cancel laserp request "laserp-573" canceled $
The Iprm command will stop the current job if the command is set by you. Otherwise, you can provide the job name as a parameter or use a dash (-) to remove all your work:
$ lprm 575 dfA575diamond dequeued cfA575diamond dequeued $
The Iprm command tells you about the file names actually removed from the print row.
Send Email in Unix / Linux
You use the mail command to send and receive mail. Here is the syntax to send an Email:
$ mail [- s subject ] [- c cc - addr ] [- b bcc - addr ] to - addr
The following table lists important functions related to mail commands:
Function -s Description Specifies subject on the command line. -c Send carbon copies to the list of users. The list can be a comma-separated list of names. -b Send blind carbon copies to the list. The list can be a comma-separated list of names.Below is an example to send a Test message to admin@yahoo.com.
$ mail - s "Test Message" admin @ yahoo . com
You are then expected to type the text into your message, followed by a D-control at the beginning of a line. To stop typing this text, simply type the dot (.) As follows:
Hi , This is a test . Cc :
You can send a full file using a redirection operator
$ mail - s "Report 05/06/07" admin @ yahoo . com < demo . txt
To check incoming messages on your Unix system, type the following email command:
$ mail no email
According to Tutorialspoint
Previous article: Instructions for installing Unix / Linux
Next article: Filter and Pipe in Unix / Linux
You should read it
- Useful commands in Unix / Linux
- Navigation IO in Unix / Linux
- System log in Unix / Linux
- ManPage Help in Unix
- Basic file system in Unix / Linux
- What is a shell?
- Regular Expression in Unix / Linux
- Network communication utilities in Unix / Linux
- Filter and Pipe in Unix / Linux
- Micro editor in Unix / Linux
- What is Unix / Linux?
- File Management in Unix / Linux
Maybe you are interested
How to use the file search command on Windows, find saved files
Why is tldr command better than man command in Linux?
Should I use PowerShell or Command Prompt?
What to do when open command window here does not appear?
How to switch users on the Linux command line
How to fix Mac Homebrew error 'zsh: command not found: brew'