Debian Codegraph @

ex45a.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 echoscip-shell system . . echo.
4 echoscip-shell system . . echo. "String operations using \"expr \$string : \" construct"
5 echoscip-shell system . . echo. "==================================================="
6 echoscip-shell system . . echo.
7
8 a=1234zipper5FLIPPER43231
9
10 echoscip-shell system . . echo. "The string being operated upon is \"`exprscip-shell system . . expr. "$a" : '\(.*\)'`\"."
11 # Escaped parentheses grouping operator. == ==
12
13 # ***************************
14 #+ Escaped parentheses
15 #+ match a substring
16 # ***************************
17
18
19 # If no escaped parentheses ...
20 #+ then 'expr' converts the string operand to an integer.
21
22 echoscip-shell system . . echo. "Length of \"$a\" is `exprscip-shell system . . expr. "$a" : '.*'`." # Length of string
23
24 echoscip-shell system . . echo. "Number of digits at the beginning of \"$a\" is `exprscip-shell system . . expr. "$a" : '[0-9]*'`."
25
26 # ------------------------------------------------------------------------- #
27
28 echoscip-shell system . . echo.
29
30 echoscip-shell system . . echo. "The digits at the beginning of \"$a\" are `exprscip-shell system . . expr. "$a" : '\([0-9]*\)'`."
31 # == ==
32 echoscip-shell system . . echo. "The first 7 characters of \"$a\" are `exprscip-shell system . . expr. "$a" : '\(.......\)'`."
33 # ===== == ==
34 # Again, escaped parentheses force a substring match.
35 #
36 echoscip-shell system . . echo. "The last 7 characters of \"$a\" are `exprscip-shell system . . expr. "$a" : '.*\(.......\)'`."
37 # ==== end of string operator ^^
38 # (In fact, means skip over one or more of any characters until specified
39 #+ substring found.)
40
41 echoscip-shell system . . echo.
42
43 exit 0