Tuesday, March 15, 2016

Uppercase to lowercase or vice versa in BASH

Uppercase to lowercase or vice versa

The bash version 4.x+ got some interesting new features. Type the following commands to convert $VAR into uppercase:


VAR="All THIS will be in UppER Case"
echo "${VAR^^}"

Sample outputs:

ALL THIS WILL BE IN UPPER CASE

Type the following commands to convert $VAR into lowercase:


VAR="All THIS will be in lOWer Case"
echo "${VAR,,}"

Sample outputs:

all this will be in lower case

No comments:

Post a Comment