The following grep
grep -r -e -n coll *
will display
fullpath/filename: <tag-name>coll</tag-name>
I would like to know what line has the following text, I tried adding -n
, but it did not work. I tried adding | grep -n *
, but it did something weird.
What I would like to see (I don't care about format) is
fullpath/filename:10: <tag-name>coll</tag-name>
no need for -r & -e !
get line number of a pattern!
if you want to get only the line number as output add another grep command to it !
You should put
-e
at the end of the options list:grep -rne coll *
To grep a pattern in a specific file, and get the matching lines:
or using
cut
as suggested by @wjandrea:where
<Pattern>
is a quoted glob pattern (use option-E
for regexp);<File>
is the file you are interested in;awk ...
filters the line numbers in the output of grep (before:
on each line);