Hi there,
I've been scouring these forums and have found similar threads, but none apparently helped me solved my problem
I'd like to run a command within a bash script, but that command is provided by the user to the script and may contain quotes, which is where the problem lies.
My script is (fundamentally):
-----
#!/usr/bin/bash
commandToRun="$@"
$commandToRun ~/t.txt
-----
And I'd like to run it using the following:
> myscript.sh grep "foo bar"
But the quotes are removed by the time I try to run that command from within the script, i.e. the $commandToRun $filename line and so it tries to run
> grep foo bar
instead of
> grep "foo bar" ~/t.txt
Thanks for any help, it would be much appreciated!
Danny