3 ms·
I have no issue with people who want to prefix grep (nor any other command for that matter) with cat. However I do completely disagree with your 2nd point. It's
by laumars 8y ago
I have no issue with people who want to prefix grep (nor any other command for that matter) with cat. However I do completely disagree with your 2nd point. It's literally just:
grep [flags] search_pattern [filename]
In GNU grep (eg Linux) it's even easier because your flags can appear wherever in the command you want (even at the end). Though I'd recommend sticking to the habit of having them after the executable name for readability and portability with non-GNU coreutils.
It's really not that hard. There's plenty worse CLI tools to use which we're now stuck with because of historic reasons.
- raverbashing 8y agoIt's easy, once you get it Take a look at the man page (linux) grep [OPTIONS] PATTERN [FILE...] grep [OPTIONS] -e PATTERN ... [FILE...] grep [OPTIONS] -f FILE ... [FILE...] Now -f does not specify the file to grep, it specifies a file where to read patterns from (and they have the same "variable" name there, confusing) Not to mention globbing and other shell escapes (which is not grep's fault, of course, but you might end up hitting in some situations)
- laumars 8y agoThat's not a typical usage of grep and nor is it even the first instruction in the man page. Let's actually take a look at the man page shall we: Synopsis grep [OPTIONS] PATTERN [FILE...] grep [OPTIONS] [-e PATTERN | -f FILE] [FILE...] That first line is more or less exactly what I posted, is your typical usage of grep, and is very easy to learn. Sure, you can list of esoteric examples of grep usage but that's besides the point if it's not how people would typically use grep (in my ~25 years of command line usage, I can't even remember one occasion when I've needed `-f` - not saying it hasn't happened but it certainly isn't something I've needed regularly)