4

Use a shell variable to execute a comand

view full story
linux-howto

http://unix.stackexchange.com – I have a unix command in a variable, it looks like this: cmd="find /path/to/webpage -type f | grep -v .svn | xargs grep $@" `$cmd` find: paths must precede expression Usage: find [-H] [-L] [-P] [path...] [expression] When I try to execute the command $cmd in a bash script, it won't work, however, when I copy and paste the exact same command, it does work. Can you let me know what I am doing wrong? I have tried putting quotes around the path, same error occurs cmd="find \"/path/to/webpage\" -type f | grep -v .svn | xargs grep $@" find: paths must precede expression Usage: find [-H] [-L] (HowTos)