我尝试了this,但这在Unix中无效。
我一直在运行这个命令:
gcc temp.c -o temp.o 2> err.txt
并收到以下错误:
gcc: 2: No such file or directory
任何想法应该不起作用?也许是因为我在Unix服务器上使用它?
答案 0 :(得分:5)
在tcsh
中,您不使用2>
重定向stderr,而是使用>&
来重定向stdout和stderr。如果您想单独重定向,请查看this quick guide。
答案 1 :(得分:1)
无法在tsch中使用2>
重定向stderr,但这里有两种解决方法
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
答案 2 :(得分:0)
你的:
gcc temp.c -o temp.o 2> err.txt
你的意思是:
gcc -o temp.o temp.c 2> err