The latter will be more like: 7:line with regex in 10-line fileĪnother executable that acts differently if it knows the file names is wc, the word counter programs: $ cat qq. While the former may give you: filename1:7:line with regex in 10-line file Is that the former knows about the individual files whereas the latter sees it as one file (with no name). The difference between that and: cat filename1 filename2 | grep -n regex When the -v or -invert-match option is also used, grep stops after outputting NUM non-matching lines. I like it because it is a quick way of search, without regexing or escaping anything. When grep stops after NUM matching lines, it outputs any trailing context lines. This will search for a matching process, but not list a grep line for the search. When the -c or -count option is also used, grep does not output a count greater than NUM. This enables a calling process to resume a search. Where you'll start seeing the difference is in variants when the extra information (the file names) is used by grep, such as with: grep -n regex filename1 filename2 When grep stops after NUM matching lines, it outputs any trailing context lines. In that sense grep regex
0 Comments
Leave a Reply. |