I have a pretty simple script that is something like the following: 我有一个很是简单的脚本,以下所示: bash
#!/bin/bash VAR1="$1" MOREF='sudo run command against $VAR1 | grep name | cut -c7-' echo $MOREF
When I run this script from the command line and pass it the arguments, I am not getting any output. 当我从命令行运行此脚本并将参数传递给它时,我没有获得任何输出。 However, when I run the commands contained within the $MOREF
variable, I am able to get output. 可是,当我运行$MOREF
变量中包含的命令时,我能够获取输出。 this
How can one take the results of a command that needs to be run within a script, save it to a variable, and then output that variable on the screen? 如何获取须要在脚本中运行的命令的结果,将其保存到变量,而后在屏幕上输出该变量? spa