You're viewing a comment by AltairIV and its responses.

AltairIV Permalink
January 14, 2013, 10:27

Oh, yeah. There's also another, poorly documented, parameter expansion that reverses the case, whatever it is.

$ str=FOObar
$ echo "${str~} ${str~~}"
fOObar fooBAR

Just like the others, a single tilde reverses only the first character, while two of them applies to the whole string.

Finally, all of the case change expansions can include an optional character or bracket list, which will restrict it to applying only if the characters in the string match.

$ echo "${str~F} ${str~[a-f]} ${str~~[bBfF]} ${str~~[^a-f]}"
fOObar FOObar fOOBar foobaR

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "floppy_326": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.