When adding an attribute to a variable with declare, the original value of the variable is not changed accordingly. How can I actually change the value of the variable according to the attribute declared? Thanks.

$ unset var; var=HELLO; declare -l var; declare -p var;
declare -l var="HELLO"

When the variable is assigned a value, all upper-case characters are converted to lower-case.

unset var; var=HELLO; declare -l var=$var; declare -p var;
declare -l var="hello"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.