Download as:
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Language:EN

Reference: expr

UNIX in a Nutshell: System V Edition

 

expr

expr arg1 operator arg2 [ operator arg3 ... ]
|
&
:

Examples

expr 5 + 10 / 2

Addition happens first; result is 7 (truncated from 7.5):

expr \( 5 + 10 \) / 2

Add 1 to variable i; this is how variables are incremented in shell scripts:

i=`expr $i + 1`
expr $a = hello
expr $b + 5 \>= 10
expr $p : '.*'        Result is 11
expr $p : '\(.*\)'    Result is "version.100"

Print the number of lowercase letters at the beginning of p:

expr $p : '[a-z]*'     Result is 7

Match the lowercase letters at the beginning of p:

expr $p : '\([a-z]*\)' Result is "version"
expr "$x" : '\(.....\)' \| "$x"
mv "$x" `expr "$x" : '\(.....\)' \| "$x"`

Previous: Reference: expand UNIX in a Nutshell: System V Edition Next: Reference: exstr
Reference: expand Book Index Reference: exstr

The UNIX CD Bookshelf Navigation
Copyright © 2009-2023 UrgentHomework.com, All right reserved.