I am working on a simple scripting project for work that involves the use of Bash. I have a pretty simple script that is something like the following:
#!/bin/bash VAR1="$1" VAR2="$2" 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. I would like to know how one can 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?