shell script

hi,
Can any body pls tell the what the following second statement does.

region="$(dirname $1)"
mixedregion="$(echo ${region%${region#?}} | tr '[[:lower:]]' '[[:upper:]]')\
$(echo ${region#?} | tr '[[:upper:]]' '[[:lower:]]')"

cheers
RRK

$ region="/db2home/training"
$ echo ${region#?}
db2home/training
$ echo ${region%${region#?}}
/

${region#?} Removes first character of region

${region%${region#?}} Removes the shortest match of ${region#?} from end of region

hi, :slight_smile:
Whats shortest match ?
cheers
RRK

${var%Pattern}
Remove from $var the shortest part of $Pattern that matches the back end of $var.
${var%%Pattern}
Remove from $var the longest part of $Pattern that matches the back end of $var.

$ str="ababac"
$ echo ${str%b*c}
abca
$ echo ${str%%b*c}
a