I have a unix shell script which uses redirection of stdout and stderr to a log file. For example test.sh:
ls -l &>> test.log
My problem is that when I run the script with sudo:
sudo ./test.sh
The & is interpreted as "run in background".
Any suggestions?
I guess, that your script test.sh does not have a shebang in the first line like this:
#!/bin/bash
Without this line several environment settings affect the way your script is executed. In your case this means that another shell like ash, ksh, dash or whatever will be used to execute the script due to the setting of the root user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With