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.
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.
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.
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.
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.
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.
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.
Similar Reads
Essential Unix Commands Unix commands are a set of commands that are used to interact with the Unix operating system. Unix is a powerful, multi-user, multi-tasking operating system that was developed in the 1960s by Bell Labs. Unix commands are entered at the command prompt in a terminal window, and they allow users to per
7 min read
Basic Linux Commands for day to day life Linux is a popular desktop, embedded, and server operating system that is strong and adaptable. Knowing the basics of commands will greatly increase your productivity and simplicity of use if you use Linux. Essential Linux commands that are useful for daily operations will be covered in this article
3 min read
What are Linux Distributions ? A Linux distribution, often shortened to âdistro,â is a packaged version of Linux that comes with the Linux kernel plus a collection of software and utilities that make the OS functional and user-friendly. Some distros are optimized for business environments, offering tools for productivity and ente
8 min read
Pros of using Linux based Operating Systems for Programming Programming is an intricate task that requires a stable, effective, and flexible operating system. Linux-based operating systems have become increasingly popular among inventors due to their multitudinous advantages. This composition explores the benefits of using Linux-based operating systems for p
5 min read
Introduction to Operating System An operating system acts as an intermediary between the user of a computer and computer hardware. In short its an interface between computer hardware and user. The purpose of an operating system is to provide an environment in which a user can execute programs conveniently and efficiently. An operat
10 min read