1

How to redirect error to a file?

view story
linux-howto

http://unix.stackexchange.com – I have this simple script which redirects the output and append it to a file. filename="/home/ronnie/tmp/hello" date=$(date) echo "$date" >> $filename Now, lets suppose I change date=$(date) to date= $(date) which will generate an error. My modified script: filename="/home/ronnie/tmp/hello" date= $(date) echo "$date" >> $filename 2>> $filename #Also tried echo "$date" >> $filename 2>&1 I was thinking that above script will redirect the error test.sh: line 5: Fri: command not found to the file hello but it just enters a new line into the file and the er (HowTos)