I have a pretty simple script that is something like the following:
(我有一个非常简单的脚本,如下所示:)
#!/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
变量中包含的命令时,我可以获取输出。)
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?
(如何获取需要在脚本中运行的命令的结果,将其保存到变量,然后在屏幕上输出该变量?)
ask by John translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…