So I'm trying to execute a command in a bash script multiple times with different but same number of arguments while redirecting the output to a text file. For example ...
./test arg1 arg2 arg3 >> output.txt
This works if I do it at the command line. In a script where I have...
command ./test 10 5 option1 >> output.txt
command ./test 5 10 option2 >> output.txt
And run the script, I get command not found
. If I remove the redirect to ouput.txt, the script then works / prints to the terminal window
I tried searching online but I could not find examples where arguments were used which then redirected
Anyone able to help?
command ./test
in the script and./test
otherwise? Please, post the actual lines that you tried. – muru Apr 21 '16 at 12:43command
only if the command is a builtin you want to override (like using a differentecho
orkill
). Well, how can you decide whether the actual program or arguments matter, when clearly you have something that should work (with or withoutcommand
), and it doesn't? Maybe one of your script's arguments is a special character. Maybe you ran the script in a different directory. Leave the decision making to us. – muru Apr 21 '16 at 12:48>
and not an append>>
. your simply trying to write into a file which dooes not exist. Or add the linetouch output.txt
above all others. There is a nice little tool which can really help you debugging scripts, its calledshellcheck
simply google for it. – Videonauth Apr 21 '16 at 12:57