mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-04-29 21:44:58 +02:00
626 B
626 B
expr
Evaluate expressions and manipulate strings.
- Get string length:
expr length {{string}}
- Evaluate logical or math expression with an operator( '+', '-', '*', '&', '|', etc. ). Special symbols should be escaped:
expr {{ARG1}} {{operator}} {{ARG2}}
- Get position of the first character in 'string' that matches 'substring':
echo $(expr index {{string}} {{substring}})
- Extract part of the string:
echo $(expr substr {{string}} {{position_to_start}} {{number_of_characters}}
- Extract part of the string which matches a regular expression:
echo $(expr {{string}} : '\({{regular_expression}}\)')