finding line number of file using grep command Linux -
i have find 250th line of txt file not have comma using grep command. file has more 250 lines, have find 250th line not.
example:
imagine had 10 line file , looking 3rd line did not contain comma lines 1 , 2 not have comma lines 3-7 have comma line 8 not contain comma answer file line 8.
i used command :
grep -vn "," test.txt
and looked 250th line, did following command see if line numbers same, , were.
grep -n "this text 250th line" test.txt
i don't think should case because 250th line of file without comma should not same line 250th line of regular file because regular file has many lines commas in them, line number should less.
what wrong here?
thank you.
unfortunately, posix disagrees:
$ man grep # ... -n, --line-number prefix each line of output 1-based line number within input file. (-n specified posix.) # ...
what toss awk
on:
$ grep -v , text.txt | awk '{ if (nr == 250) { print } }'
Comments
Post a Comment