I am greping a string from multiple files, but the one undesired side effect, is the filename prefacing the output. How can I suppress the filename outputs using only grep?
$ grep -i lp lpNet* lpNet:This was printed via the internet using the lp command. lpNet:I believe lp doesnt care what the device is. lpNet1:This was printed via the internet using the lp command. lpNet1:I believe lp doesnt care what the device is. lpNet2:This was printed via the internet using the lp command. lpNet2:I believe lp doesnt care what the device is. lpNet3:This was printed via the internet using the lp command. lpNet3:I believe lp doesnt care what the device is. I have solved the issue for now using cat lpNet* | grep lp I am just wondering if there is a more efficient path to have the same effect
1 Answer
The default behavior is to print the filename when given multiple file arguments - to suppress this, you can add the -h or --no-filename option
From the Output Line Prefix Control section of the grep manual page:
-h, --no-filename Suppress the prefixing of file names on output. This is the default when there is only one file (or only standard input) to search.