michael_J
michael_J

Reputation: 143

What does ${var,,} mean in Bash?

example:

a=$( printf "%X" 10 )
b=${a,,}

anyone knows what is the difference between the value for variable a and variable b? what the purpose of the second expression?

Upvotes: 1

Views: 70

Answers (1)

iamauser
iamauser

Reputation: 11479

$ a=$(printf "%X" 10) # assign the HEX conversion value in upper case.
$ echo "${a}" # Print the value
A
$ echo "${a,,}"  # Parameter expansion to bring everything to lowercase
a
 

Instead of assigning b=${a,,}, you can do,

$ b=$(printf "%x" 10)
$ echo "$b"
a

Parameter Expansion

Printf command

Upvotes: 2

Related Questions