4 ms·
> Sometimes I end up passing the help output through grep, then copy-pasting the flags from the output, and then hoping I got the right flag. man x | grep -P
by larkeith 8y ago
> Sometimes I end up passing the help output through grep, then copy-pasting the flags from the output, and then hoping I got the right flag.
man x | grep -P y -C 3 | less
...is my standard here (-C 3 includes the pre- and succeeding 3 lines). For all the delights of CLIs, man pages are by default opaque walls of text. And dear lord the number of regex variants... - at this point, if at all possible, I'll avoid application-specific flavours entirely, and just pipe to grep -P (perl-style regex).
I might suggest, however, that image/video manipulation is a case for which CLIs are uniquely unsuitable.
There surely are better ways (as you mentioned, Powershell appears to be a step or three in the right direction, though I have little familiarity with it), but it seems as though the greatest difficulty is in maintaining full backwords compatibility, while still encouraging new applications to make full use of novel features - not to mention the effort of modifying old applications to fit new standards that would need be expended.
- azernik 8y agoIf you're already piping to less, just use its search functionality; type '/', the regexp, and then enter.
- pdpi 8y agoFor that, you might as well just use the regex functionality in man itself too. But that misses the point. The goal of grepping in that snippet is that you're `less `ing through precisely the parts that matter, and no more, rather than wading through the whole man page, and you're using -C to control how much context you (think you) need around the search results. This is a much better setup for skimming through potential hits than going through the man page wall of text.
- mrcarrot 8y agoYou can also do that directly in 'man'.
- JdeBP 8y agoNo. All three of the responders so far have implied that this functionality is in man. It is not. It's in the pager that man invokes; ironically often, but not necessarily always, that very same less program.
- larkeith 8y agoIIRC you don't need to pipe to less at all for that - man already supports it. grep -C gives a good summary of the various options, then you can just pull up the man page and use that selfsame search to get details that might've been cut off.