I was trying to pass a variable another shell command.
To be clear;
passwdContent=$( getent passwd "$USER" )
echo "passwdcontent" $passwdContent
I get the "passwd" field from user "x".
After this section I want to play with this variable.
But in here I couldn't solve how can I pass the "passwdContent" variable.
I tried a way like this;
exampleVariable=[( "$passwdContent" | cut -d : -f 1 )]
After I want to echo the "exampleVariable" it gave me error.
I knew I can do this all of in one line. But I want to learn how can I do this.
Best Answer
You should use command substitution and for doing that you are missing a
$
.You should also
pipe
the content of your variable tocut
or read it fromstdin
.So use this instead:
Now: