1

For some reason whenever I try to redirect errors to file using 2> it doesn't work and I get a message that treats the '2' and '>' as separate.

Strangely enough, when I press the up arrow to return to the previous command an extra space is added so that 2> becomes 2 > even though this is not what I wrote.

For example, if I type:

rm dir1 2> err1

It doesn't forward the error to the file. When I press the up arrow the line turns into:

rm dir1 2 > err1

I would greatly appreciate any insights regarding this quite strange issue. Thanks

Etan Reisner
  • 77,877
  • 8
  • 106
  • 148
Ron
  • 143
  • 6

1 Answers1

0

You're not using bash according to your comment, in tcsh you can't redirect only one standard stream to a file, but you can redirect all the streams at once by using >& like so

rm dir >& outputfile1

See this answer for more info

Community
  • 1
  • 1
Ritave
  • 1,333
  • 9
  • 25
  • Thanks. I tried changing to bash by "chsh -s /bin/bash" but got "Insecure dependency in system while running setuid at /usr/local/etc/acct.new/acct_admin line 45. Any ideas? – Ron Oct 28 '15 at 16:44
  • You can try calling ```/bin/bash``` directly to get bash for this session only. If that doesn't work you may need to contact your sysadmin about supporting bash. Still csh redirection should work because ```rm``` is silent, please **do** try ```rm dir1 >& output.file``` before trying to fumble with bash. – Ritave Oct 28 '15 at 16:48
  • @Ron add some enviroment info: such as OS Type. By the way it may possible to change in the [/etc/passwd](http://linux.die.net/man/5/passwd) file the default shell for some user. – Thomas8 Oct 28 '15 at 16:52
  • Thanks. I need to use "bash" since it is for a class. My terminal was supposed to be bash, maybe it is an error the admin needs to fix... I don't know the exact OS of the terminal except that it is Linux.. – Ron Oct 28 '15 at 17:03