How to display line numbers?

QuestionsQuestions4 SkillsProUser Account ManagementOct, 07 2025
0170

To display line numbers along with the output of grep, you can use the -n option. Here’s how to do it:

grep -n 'pattern' filename

Example

If you want to search for the word "joker" in the /etc/passwd file and display line numbers, you would use:

grep -n 'joker' /etc/passwd

This command will show each matching line preceded by its line number in the file. If you have any more questions or need further assistance, feel free to ask!

0 Comments

no data
Be the first to share your comment!