How do I render a bash script with the variables expanded?
How can you display a Bash script with its variables expanded. I want to see what the script would actually execute, without doing 开发者_如何学Goanything.
There are three relevant options:
-n
- do not execute-v
- show the code as it is read-x
- show the code as it is executed
AFAIK, you can't see the expanded variables with -n
in effect, but you can't avoid executing code unless -n
is in effect. So, roughly, you have to execute the script to see the expanded variables.
You can use the -x
option of bash
as:
$bash -x myscript.sh
If you don't execute the variable assignments then there's nothing to expand.
prefix your commands with echo
?
精彩评论