Extract all variable values in a shell script
问题 I'm debugging an old shell script; I want to check the values of all the variables used, it's a huge ugly script with approx more than 140 variables used. Is there anyway I can extract the variable names from the script and put them in a convenient pattern like: #!/bin/sh if [ ${BLAH} .... ..... rm -rf ${JUNK}..... to echo ${BLAH} echo ${JUNK} ... 回答1: Try running your script as follows: bash -x ./script.bash Or enable the setting in the script : set -x 回答2: You can dump all interested