How to display line number while doing grep on a file. For example:
grep CONFIG_PM_ADVANCED_DEBUG /boot/config-`uname -r
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
There is the option
-n, and many more in the manual page, worth reading.
grep -n <pattern> <file> prefixes each line of output with the line number in the input file. Is this what you are looking for?
alias grep='grep -inE --color=auto'
This will color the match as well for easy reading.
Have you checked
cat -n 'filename'. This will print the line numbers.
cat -n /boot/config | grep CONFIG_PM_ADVANCED_DEBUG
-n[umber] the lines and
| (filter) through
grep looking only for lines with
CONFIG_PM.... in them
the resulting output will be line number; the text of the line and the string
cat -n[umber lines] /Path/to/filename | grep -i[gnor case (optional)] STRING_TO_LOOK_FOR