Linux - Prints line numbers using grep command, Count line using grep command

Prints line numbers using grep command


You can get line number's of a file using grep command.

Syntax
 grep -n "^" <filename>

Example
 grep -n "^" tags.txt

OUTPUT
 1:<html> 
 2:<head> </head>
 3:<title> </title>
 4:<body> 
 5:</body>
 6:
 7:</html>

The above command will also count the blank lines and prints the result as above.

The topic on Linux - Prints line numbers using grep command is posted by - Maha

Hope you have enjoyed, Linux - Prints line numbers using grep commandThanks for your time

Tech Bluff