开发者

How do I render a bash script with the variables expanded?

开发者 https://www.devze.com 2023-01-17 22:18 出处:网络
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:

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消