I'm attempting to re-use parameters sent to my script as parameters for a command I execute within my script. See example below where I execute mailx.
bash
$./myscript.sh "My quoted Argument"
myscript.sh
mailx -s $1
This ends up being executed as: mailx -s My Quoted Argument.
- I tried
"$1", but my quotes are thrown away. (Incorrect statement, read answer below) - I tried
""$1""but my quotes are thrown away. - I tried to do
'$1'but that's strong quoting so $1 never gets interpreted. - I realize I can do
$@, but that gives me every param. - .... you get the picture
Any help would be appreciated!