Timeline for Recursive search for a pattern, then for each match print out the specific SEQUENCE: line number, file name, and no file contents
Current License: CC BY-SA 3.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 17, 2013 at 13:02 | comment | added | Gilles 'SO- stop being evil' | @JohnSonderson ”-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.“ If you want correct output for file names containing colons, you can't use grep, not without a complex shell wrapper. You can use awk, see my edit. | |
| Oct 17, 2013 at 13:00 | history | edited | Gilles 'SO- stop being evil' | CC BY-SA 3.0 | show how to do the search in awk |
| Oct 17, 2013 at 12:40 | comment | added | John Sonderson | As to invoking awk in this way, perhaps I have not been clear, but if the field separator (specified after -F) which is the colon (:), appears in the filename, which is printed before the line number, then your command using awk will not work. | |
| Oct 17, 2013 at 12:39 | comment | added | John Sonderson | Your explanation concerning why the second option is so slow is very clear. Thanks. As to the -H flag, my man page says "Print the file name for each match. This is the default when there is more than one file to search." So it seems like it might not be needed. I don't know why, but the man page doesn't specify what happens in the case where there is only one file to match, perhaps someone can comment. | |
| Oct 17, 2013 at 0:09 | history | edited | Gilles 'SO- stop being evil' | CC BY-SA 3.0 | added 473 characters in body |
| Oct 16, 2013 at 23:59 | history | answered | Gilles 'SO- stop being evil' | CC BY-SA 3.0 |