Skip to Content
gnux

-n, --line-number

Print the line number with output lines.

An option of grepx.

Usage

grepx -n PATTERNS [FILE]...
grepx --line-number PATTERNS [FILE]...

Details

ShortLongValueDefaultMeaning
-n--line-numbernoneprint the line number with output lines

Examples

Search a source tree for a whole word, with file names and line numbers

grepx -rnw 'TODO' src
Output
src/main.go:42:    // TODO: handle the empty case

Search a tree but skip the dependency and VCS directories

grepx -rn --exclude-dir=node_modules --exclude-dir=.git 'fetch(' .

Stop after the first three matches and number them

grepx -n -m 3 'panic' crash.log

Search in the portable gnux shell, the same on every platform

gnux shell -c 'catx notes.txt | grepx -n urgent'

Help in the terminal

gnux help grepx --line-number

On this page