Linux 无法在文件中获取错误

Linux 无法在文件中获取错误,linux,Linux,可能是个天真的问题,但我被卡住了 我有一个shell脚本file.sh,其中包含一个简单的命令(我没有安装python) echo$PATH&&cd/home/akash/repos/dhvani/&&echo$PWD&&python main.py 当我以sh file.sh>/tmp/out的形式运行它时。我在/tmp/out中得到了echo的部分,但没有得到错误。我没有安装python,所以我必须在文件中得到类似python:notfound的错误。但我只在候机楼看到 有人能解释一下如何记

可能是个天真的问题,但我被卡住了

我有一个shell脚本
file.sh
,其中包含一个简单的命令(我没有安装
python

echo$PATH&&cd/home/akash/repos/dhvani/&&echo$PWD&&python main.py

当我以
sh file.sh>/tmp/out
的形式运行它时。我在
/tmp/out
中得到了
echo
的部分,但没有得到错误。我没有安装
python
,所以我必须在文件中得到类似
python:notfound
的错误。但我只在候机楼看到


有人能解释一下如何记录此错误。

要使
stderr
以及
stdout
转到该文件,请执行以下操作:

sh file.sh > /tmp/out 2>&1

要使
stderr
以及
stdout
转到该文件,请执行以下操作:

sh file.sh > /tmp/out 2>&1