bash - Using expr, $(()), (()) - Unix Linux Stack Exchange expr can do this without a pipe: if expr november : nov then : do something fi the only catch is expr works with anchored strings, so if you want to match after the beginning you need to change the REGEXP: if expr november : ' *ber' then : do something fi Regarding (( )), this construct is not POSIX, so should be avoided
Adding two numbers using expr - Unix Linux Stack Exchange expr is an external program used by Bourne shell(i e sh) Bourne shell didn't originally have any mechanism to perform simple arithmetic It uses expr external program with the help of backtick The backtick(`) is actually called command substitution Command substitution is the mechanism by which the shell performs a given set of commands
Understanding of the regexp match feature of the expr utility What is expr doing in these two commands? For the first command, it seems expr found a match from the first character of abc and reports the matched length But why does it produce 0 for the second command?
shell - Parenthesis in expr arithmetic: 3 * (2 + 1) - Unix Linux . . . Furthermore, expr needs each number and operator to be passed as a separate parameter Thus: expr 3 \* \( 2 + 1 \) Unless you're working on an antique unix system from the 1970s or 1980s, there is very little reason to use expr In the old days, shells didn't have a built-in way to perform arithmetic, and you had to call the expr utility
shell script - OR in `expr match` - Unix Linux Stack Exchange expr match Unauthenticated123 'Unauthenticated\|Authenticated' If you want the number of characters matched To have the part of the string (Unauthenticated) returned use: expr match Unauthenticated123 '\(Unauthenticated\|Authenticated\)' From info coreutils 'expr invocation': `STRING : REGEX' Perform pattern matching
bash - What is expr doing when processing arrays? - Unix Linux Stack . . . expr substr will expect numbers, you give to it many text words, so it will complain about too much arguments and their bad type I am not sure, what are you trying to do with this substring - an array might have a range, or a "sub-array", or an interval but I am not sure, how you define the substring of an array
scripting - What is the difference between bcl and expr? - Unix Linux . . . For one thing, bc supports big numbers while expr tops out at 2^63-1: $ expr 9223372036854775807 + 1 -9223372036854775807 $ echo "9223372036854775807 + 1" | bc 9223372036854775808 bc also has exponentiation and square root operations, which expr lacks entirely:
Substring extraction with expr - Unix Linux Stack Exchange man expr says the "STRING : PATTERN" expression is "anchored", and then in the info page (info coreutils 'expr invocation') you can read: `STRING : REGEX' Perform pattern matching The arguments are converted to strings and the second is considered to be a (basic, a la GNU `grep') regular expression, with a `^' implicitly prepended
bash - Why should I use $[ EXPR - Unix Linux Stack Exchange On the paragraph explaining arithmetic expansion, Bash's user guide uncovers 2 different ways of evaluating an expression, the first one uses $(( EXPRESSION )) and the second one uses $[ EXPRESSION
expr: unexpected operator - Unix Linux Stack Exchange Stack Exchange Network Stack Exchange network consists of 183 Q A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers