Return to BSD News archive
Xref: sserve comp.unix.questions:57137 comp.unix.aix:46757 comp.unix.bsd:15227 comp.unix.misc:14545 comp.unix.programmer:21171 comp.unix.shell:18723 comp.unix.solaris:25813 comp.unix.user-friendly:2927 Path: sserve!newshost.anu.edu.au!munnari.oz.au!spool.mu.edu!howland.reston.ans.net!gatech!purdue!mozo.cc.purdue.edu!not-for-mail From: pacman@expert.cc.purdue.edu (Equation Man) Newsgroups: comp.unix.questions,comp.unix.aix,comp.unix.bsd,comp.unix.misc,comp.unix.programmer,comp.unix.programmers,comp.unix.shell,comp.unix.solaris,comp.unix.user-friendly Subject: Re: No subject Date: 28 Oct 1994 23:39:51 -0500 Organization: Huh? Lines: 44 Distribution: inet Message-ID: <38sjmn$rl3@expert.cc.purdue.edu> References: <091312Z28101994@anon.penet.fi> <38qje9$111q@rs18.hrz.th-darmstadt.de> NNTP-Posting-Host: expert.cc.purdue.edu In article <38qje9$111q@rs18.hrz.th-darmstadt.de>, Arno Schaefer <schaefer@rbg.informatik.th-darmstadt.de> wrote: :In article <091312Z28101994@anon.penet.fi>, an141226@anon.penet.fi writes: : :> find: cannot read dir ./lost+found: Permission denied :> find: cannot read dir ./c2/lost+found: Permission denied :> find: cannot read dir ./export/lost+found: Permission denied :> etc, etc... FOREVER! :> :> Is there a way to suppress these error messages? Or have find ignore :> errors? I tried the man pages and saw the -perm switch, but that didn't :> work. Any ideas? Is this possible on a unix system? : :find . -name ytalk -print 2>/dev/null : The perfect answer, if his shell is of the Bourne family. To the anonymous poster: Specify your shell when you ask a question. You've run into the most often cited difference between Bourne shells and C shells, file descriptor handling (specifically stderr redirection.) If you're putting this in a script (though I can't imagine why you would be) and you haven't written a lot of hard-to-translate code in csh yet, use sh. If you want to run this from your login shell, and it happens to be [t]csh, the above solution will not work. Stderr redirection is something C shells don't do in a straightforward way, but if you're sneaky, you can fool them into doing it. Here's the [t]csh way: (admittdly less efficient, but less confusing than telling the guy to change his shell.) (Extra clue: look at the nature of the command. This is a one-timer, for sure. Efficiency isn't necessarily the highest priority.) find . -name ytalk -print |& grep -v 'Permission denied' or find . -name ytalk -print |& grep ytalk These do require a grep that the sh answer doesn't, so here's another: (find . -name ytalk -print >/dev/tty) >& /dev/null Not really better since it creates a subshell, but hey it'll work. Oh, this find is maybe something you didn't want on your tty, so substitute an appropriate filename for /dev/tty if desired.