Re: Bash Command Substitution - strange effect
cat the script and look at the echo commands. perhaps you added the echo commands to the script via an echo command. if so then, what would happen is the `id -un` got evaluated when the command to add it to the script happened. did you do this?
Code:
echo "echo `id -un`" >> name-of-script
if you did that then the `id -un` would be evaluated at the time of appending. and the result would be the same as if you did:
Code:
echo "echo root" >> name-of-script
double quote allows shell evaluation inside, including variable substitution and $(). but single quotes do not. by using single quotes this issue can be prevented.
Code:
echo 'echo `id -un`' >> name-of-script
i'm just guessing that maybe this is what you did. you can cat the file if you don't remember. bash easily can do many things in unexpected contexts giving very unexpected results.
Mask wearer, Social distancer, System Administrator, Programmer, Linux advocate, Command Line user, Ham radio operator (KA9WGN/8, tech), Photographer (hobby), occasional tweetXer