I have a bash script that takes a name and a command as arguments. Its pretty simple like this,
#myscript
echo $1
$2
And I run this like this
bash myscripts myjob ls
and it will echo the 'myjob' and run the ls
command. But when the command is multi-word, I have to provide it with an inverted commas, like this
bash myscripts myjob "ls -l"
Now my question is, is there a way to write the shell script so that, I don't have to provide the inverted commas? Like, take everything as my command instead of the first argument? Is it possible to do with bash?
"$@"
) already contain the command to run as separate words so where to put them is not the problem. But you can modify and use the list as in that other question. – ilkkachu Dec 10 '21 at 15:18