Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 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. Commented Oct 17, 2013 at 12:39
  • 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. Commented Oct 17, 2013 at 12:40
  • @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. Commented Oct 17, 2013 at 13:02