I want to store error of unix command into file.
Ex. cd /test /test: No such file or directory. I want to store error "/test: No such file or directory." into file
Can you please help?
How about
cd /test 2> myFile.txt
cd /test &> myFile.txt2> for redirecting stdout is correct. &>will redirect both stdout and stderr (see [gnu.org/software/bash/manual/html_node/Redirections.html]).if cd /test 2>myFile.txt; then : do work in new; else : handle failure; fi. Note that the log file will be created in the original directory.