In my script in bash, there are lot of variables, and I have to make something to save them to file. My question is how to list all variables declared in my script and get l
Try this : set | egrep "^\w+="
(with or without the | less
piping)
The first proposed solution, ( set -o posix ; set ) | less
, works but has a drawback: it transmits control codes to the terminal, so they are not displayed properly. So for example, if there is (likely) a IFS=$' \t\n'
variable, we can see:
IFS='
'
…instead.
My egrep
solution displays this (and eventually other similars ones) properly.