3 ms·
If you want to do (relatively) simple pattern matching in a posix-compliant way, `expr`[1] can match BREs, and even return a capture group. 1: https://pubs.ope
by stephenr 3y ago
If you want to do (relatively) simple pattern matching in a posix-compliant way, `expr`[1] can match BREs, and even return a capture group.
1: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/expr.html https://pubs.opengroup.org/onlinepubs/9699919799/utilities/e...
- somat 3y agoAs someone who enjoys shell scripting I don't think I have ever used the "expr" command. this astonishes and baffles me because I used to read the man pages for fun, I even had a little script to pick a random page. So thanks a bunch for bringing it to my attention. My only guess as to why I am unfamiliar with the command is that perhaps younger me failed to figure out "expression" means regular expression. It only clicked this time because of your comment and the see also: re_format link at the bottom. http://man.openbsd.org/expr http://man.openbsd.org/expr
- stephenr 3y agoYeah it's slightly obscure for a lot of people I think: most who do know of it seem to associate it purely with arithmetic, and rightly use `$((...))` instead.