2

I have the following code in tcsh:

set dirs = `find $path -follow -name "test" | grep -v ".data"`

It will find all the directories that have test directory under it, without including .data.

I noticed that if there is some problem while running find, for example, a broken link on the way, I'll get a "permissions denied" error and then the tcsh script is just hanging until I manually kill it. I'm trying to catch all the errors and redirect them to /dev/null and the output to redirect to grep.

I came across with different answer. For example, there was a topic that suggested to ignore only "permission denied" - which worked, but I'm trying to redirect all the errors to /dev/null and not just one. But the problem is the pipe | - how can I redirect the stderr to /dev/null and the stdout to the pipe (which is grep)?

vesii
  • 203
  • You should use another shell for those tasks. But if you want to use tcsh you can use this: ( find $path -follow -name "test" | grep -v ".data" > chsout.txt ) > & /dev/null. You have to redirect the stdout to a file and read its content later (assign a variable it seems doesn't work. I'm not sure how should a variable be assigned.) – Edgar Magallon Oct 18 '22 at 20:11

0 Answers0