英文:
How to specify the stderr file in the bash script?
问题
我有一个简单的bash脚本:
#!/bin/bash
一些bash代码....
并且在启动它时:
./myscript.sh
我想将错误重定向到error.err文件,并且我想在myscript.sh文件中指定该文件的名称(这里是:error.err)。
(所以我想避免这样做:./myscript.sh 2>error.err
)
这可行吗?
非常感谢
英文:
I have a simple bash script:
#!/bin/bash
Some bash code....
And when starting it with:
./myscript.sh
I would like to redirect the error into error.err file, and I would like to specify the name of this file (here: error.err) inside myscript.sh file.
(so I would like to avoid doing: ./myscript.sh 2>error.err
)
Is it possible
Thanks a lot
答案1
得分: 0
exec 2>error.err
英文:
Just prepend the following line to the script
exec 2>error.err
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论