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

  1. Using cat command with option -n

  2. Using bat command without option

  3. 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

Popular posts from this blog

Vivo V30 Pro 5G

Xiaomi 14 - Features, Price

Oppo F25 Pro 5G Review - Features, Price