The Wayback Machine - https://web.archive.org/web/20240805050455/https://www.geeksforgeeks.org/pr-command-in-linux/
Open In App

pr command in Linux

Last Updated : 28 Jan, 2022
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report

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 the 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



Similar Reads

uniq command in Linux with examples
The linux uniq command is basically used to remove all repeated lines in a file. This command is used when a line is repeated multiple times and replace these multiple lines with one line. This command is designed to work on sorted files. Purpose : Remove repetitious lines from the sorted 'input-file' and send unique lines to the 'output-file'. If
2 min read
How to List Current Logged-In Users in Linux | who Command
Linux, being a powerful and versatile operating system, provides several command-line tools to manage and monitor user activity. One common administrative task is to identify and list the currently logged-in users on a Linux system. In this article, we will delve into multiple ways to achieve this, exploring commands such as who, user, w, last, fin
5 min read
'IPCS' command in Linux with examples
ipcs shows information on the inter-process communication facilities for which the calling process has read access. By default, it shows information about all three resources: shared memory segments, message queues, and semaphore arrays. Without options, the information shall be written in short format for message queues, shared memory segments, an
3 min read
Linux Virtualization : Linux Containers (lxc)
Operating-system-level virtualization is a server virtualization method in which an operating system's kernel allows multiple isolated user-space instances, instead of just one. Such instances, which are sometimes called containers, software containers, virtualization engines (VEs), or jails (FreeBSD jail or chroot jail), may look and feel like a r
6 min read
getopt() function in C to parse command line arguments
The getopt() function is a builtin function in C and is used to parse command line arguments. Syntax: getopt(int argc, char *const argv[], const char *optstring) optstring is simply a list of characters, each representing a single character option. Return Value: The getopt() function returns different values: If the option takes a value, that value
2 min read
cmd | cls command
Cls is a internal command found inside windows command interpreter cmd, that is used for clearing the console window. It does so by removing the entry of all previously entered commands, and their corresponding outputs. The command was first introduced in the MSDOS Version 2. Initially it was for command.com (command processor for MSDOS), which is
2 min read
Command Line Arguments in Java
Java command-line argument is an argument i.e. passed at the time of running the Java program. In Java, the command line arguments passed from the console can be received in the Java program and they can be used as input. The users can pass the arguments during the execution bypassing the command-line arguments inside the main() method. Working com
3 min read
Useful and time saving bash commands in Linux
There are many useful bash scripts that can make things easier. Many things can be done just using the terminal. Here is a list of some of such useful bash scripts through which we can do things that cannot be done manually. 1. Counting the number of files(or directory) in a given directory: Go to the directory in which you want to count the number
3 min read
Processes in Linux/Unix
A program/command when executed, a special instance is provided by the system to the process. This instance consists of all the services/resources that may be utilized by the process under execution. Whenever a command is issued in Unix/Linux, it creates/starts a new process. For example, pwd when issued which is used to list the current directory
6 min read
halt, poweroff and reboot Commands in Linux
Below are typical uses of halt, poweroff and reboot. halt : Instructs hardware to stop CPU functions. poweroff : Instructs the system to power down. reboot : Restarts or reboots the system. The above mentioned commands can only be run by super user as these involve the actions to stop the system hardware. If the user is not logged in as super user
2 min read
Article Tags :
Practice Tags :
three90RightbarBannerImg