when doing something like this:
cat *.* | grep mystring
is it possible to know from which file each match comes from? If not what would be the alternative?
Use grep -l:
-l, --files-with-matches
Suppress normal output; instead print the name of each input file from
which output would normally have been printed.
E.g.
$ echo foo > file1
$ echo bar > file2
$ grep -l foo *
file1
Or with line numbers where the string occured:
$ grep -rn foo .
file1:1:foo
grep mystring *.*
grep -H mystring *.*
works perfectly adequately (-H
in case*.*
matches only one file).cat
has no option to display file names, so once you have enteredcat *.*
there can be no way to show file names.