How does the -n parameter modify the output of the cat command?

The -n parameter in the cat command modifies the output by numbering all lines of the displayed content. When you use this option, each line will be prefixed with its corresponding line number, starting from 1.

Example:

cat -n filename.txt

Effect:

If filename.txt contains:

Hello, World!
This is a test file.
It has multiple lines.

The output with the -n option will look like this:

     1  Hello, World!
     2  This is a test file.
     3  It has multiple lines.

This makes it easier to reference specific lines in the file, especially useful for longer texts. If you have more questions or need further clarification, feel free to ask!

0 Comments

no data
Be the first to share your comment!