3 Linux Tips to Show File Contents with Line Numbers
Tamizh Tech Tutorial
3 Linux Tips to Show File Contents with Line Numbers
(3 Examples)
In this tutorial, you will learn 3 tips to display the file contents along with line numbers in linux / unix with examples
Three Tips
Using cat command with option -n
Using bat command without option
Using nl command without option
1. Using cat command with option -n
This command is used to display the file contents with special option -n
Syntax
cat -n filename
Where,
filename is an existing input filename.
Example
2. Using bat command
This is the latest linux command, similar to cat command
This command is also used to display the file contents without any option.
NOTE
By default, this command is not installed on your machine. So you need to install it externally based on your distribution before using it.
Syntax
bat filename
Where,
filename is an existing input filename.
Example
3. Using nl command
nl stands for line numbers, an alternative to cat command
This command is also used to display the file contents with line numbering, without using any arguments.
Syntax
nl filename
Where,
filename is an existing input filename.
Example
Comments
Post a Comment