我試過this,但這在Unix中不起作用。如何將gcc錯誤重定向到Unix中的文件?
我一直在運行此命令:
gcc temp.c -o temp.o 2> err.txt
而且得到了以下錯誤:
gcc: 2: No such file or directory
任何想法是不應該工作?也許是因爲我在Unix服務器上使用它?
我試過this,但這在Unix中不起作用。如何將gcc錯誤重定向到Unix中的文件?
我一直在運行此命令:
gcc temp.c -o temp.o 2> err.txt
而且得到了以下錯誤:
gcc: 2: No such file or directory
任何想法是不應該工作?也許是因爲我在Unix服務器上使用它?
在tcsh
中,您不使用2>
重定向stderr,您使用>&
將重定向stdout和stderr。如果你想單獨重定向他們,看看this quick guide。
重定向使用2>
在TSCH是不可能的標準錯誤,但是這裏有兩個變通
bash -c "gcc temp.c -o temp.o 2> err.txt" #if bash or sh is available
(gcc temp.c -o temp.o > /dev/null) > & err.txt
此致:
gcc temp.c -o temp.o 2> err.txt
你肯定是說:
gcc -o temp.o temp.c 2> err
什麼殼是你運行? ('echo $ SHELL'可能會顯示你) – 2012-02-24 18:57:02
@JoachimIsaksson -/bin/tcsh – RanZilber 2012-02-24 18:57:58