pr command in Linux

In Linux/Unix pr command is used to prepare a file for printing by adding suitable footers, headers, and the formatted text. pr command actually adds 5 lines of margin both at the top and bottom of the page.  The header part shows the date and time of the last modification of the file with the file name and the page number. 

Syntax:

pr [options][filename]

Working with pr command

1. To print k number of columns we use -k. Let’s say, we have a file that contains 10 numbers from 1 to 10 with every number in a new line. 

pr command in linux

Now if we want to print this content in 3 columns we will use the following command.



pr -3 abc.txt
here abc.txt is the name of file.

pr command in linux

2. To suppress the headers and footers the -t option is used.

pr -t abc.txt

After executing the above command it will give us the following output.

pr command in linux

3. To Double the paces input, reduces clutter -d option is used.

pr -d abc.txt

After executing the above command it will give us the following output.
 

pr command in linux

4. To provide number lines which helps in debugging the code -n option is used.



pr -n abc.txt

After executing the above command it will give us the following output.
 

pr command in linux

5. To print the version number of the command –version is used. 

pr --version

After executing the command, it will return us the version in the below mentioned format.
 

pr command in linux

6. To open he help section of the command or to get the details of all the options and attributes of the command –help is used.

pr --help

After executing the command, it will return us the help section in the following way.

pr command in linux

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.