4

I tried following this but that doesn't work in Unix.

I've been running this command :

gcc temp.c -o temp.o 2> err.txt

And got the following error:

gcc: 2: No such file or directory

Any ideas what that shouldn't work? Maybe because I’m using it over a Unix server?

Community
  • 1
  • 1
RanZilber
  • 1,840
  • 4
  • 31
  • 42

3 Answers3

6

In tcsh you don't use 2> to redirect stderr, you use >& that will redirect both stdout and stderr. If you want to redirect them separately, have a look at this quick guide.

Joachim Isaksson
  • 176,943
  • 25
  • 281
  • 294
1

Redirecting stderr using 2> in tsch is not possible, but here are 2 work arounds

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
Alex
  • 10,470
  • 8
  • 40
  • 62
0

Yours:

gcc temp.c -o temp.o 2> err.txt

you sure mean:

gcc -o temp.o temp.c 2> err
Tom
  • 16,842
  • 17
  • 45
  • 54