Quote:
Originally Posted by Dick Dastardly
1) What does the "original=()" do?
|
It sets
original to an empty array.
Quote:
Originally Posted by Dick Dastardly
2) What do the slashes do in the if test "if [ "$one" = "${one/XXX/}" ]; then"?
|
It is a string operation, described in detail in the
Bash Reference Manual (Shell Parameter Expansion chapter).
Put simply,
${variable/pattern/replacement} evaluates to the value of
variable but with the first
pattern replaced by
replacement.
There are other similar expressions explained in the link above. For example,
${variable//pattern/replacement} evaluates to the value of
variable but all
patterns replaced by
replacement.
Note that the
pattern is actually a
glob pattern, similar to the patterns you use to specify file name patterns. Its syntax is explained in the
Pattern Matching section in the Bash Reference Manual.
It is easy confuse these glob pattern string expressions with regular expressions, which look similar, but have different special characters. It is a good thing you asked.