Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Standard Error Redirect in TCSH script

I'm trying to make a simple TCSH script that effectively emulates find and outputs to a file; in addition I want to eliminate any error messages sent to Standard Error.

#!/bin/tcsh

ls $argv > filelist 2> /dev/null

The find portion of the script seems to work as should, but the Standard Error redirect doesn't. What's the best way to "eliminate" error messages?

like image 915
user3598616 Avatar asked Mar 10 '26 23:03

user3598616


1 Answers

The syntax you tried is bashy. In tcsh, you can do:

(ls $argv > filelist) >& /dev/null

Note that >& redirects both stdout and stderr, but since stdout has already been redirected elsewhere only the stderr will make it through to /dev/null.

like image 74
shx2 Avatar answered Mar 12 '26 16:03

shx2



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!