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!
