home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!casbah.acns.nwu.edu!navarra
- From: navarra@casbah.acns.nwu.edu (John Navarra)
- Subject: More problems with find (the stderr bug)
- Message-ID: <1992Sep7.030046.18575@news.acns.nwu.edu>
- Sender: usenet@news.acns.nwu.edu (Usenet on news.acns)
- Organization: Northwestern University, Evanston Illinois.
- Date: Mon, 7 Sep 1992 03:00:46 GMT
- Lines: 72
-
-
- Here is an interesting little problem with the find command:
-
- I want to remove certain files with my userid in the /tmp directory.
- Here is the command I tried:
-
- [casbah:219] ~/tmp -> find /tmp -user navarra -ok /bin/rm {} \; 2>/dev/null
-
- This finds all the files with my userid in /tmp and prompts me in turn
- if I want to remove the file. Now, the problem is the redirect to
- /dev/null. The rationale for doing this is so I won't see things like:
-
- cannot change directory to blah: Permission denied.
-
- However, when I run this command, it just hangs. At first, I thought it
- had something to do with the way I constructed the command. I ruled that
- out. Then, I thought it had something to do with my shell (bash) but I
- ruled that out by trying other sh-shells (remembering that redirecting
- stderr in csh/tcsh is real *fun* -- read stupid). So, then I figured
- it had something to do with my OS (SunOS) but no, that wasn't it
- either!
-
- Then it was time to look at the man page again:
-
- -ok command Like -exec except that the generated command
- is written on the standard output, then the
- standard input is read and the command exe-
- cuted only upon response y.
-
- Now read that. It *says* it writes to standard output right?
-
- Well:
- [casbah:226] ~ -> find /tmp -user navarra -ok /bin/rm {} \; 2>yeah_right
- n
- n
- n
- n
- screw you find!
- yeah whatever
- ^C
- [casbah:227] ~ -> cat yeah_right
- find: cannot chdir to /tmp/screens/S-jeff: Permission denied
- find: cannot chdir to /tmp/screens/S-triona: Permission denied
- < /bin/rm ... /tmp/screens/S-navarra >? find: cannot chdir to
- /tmp/screens/S-j
- find: cannot chdir to /tmp/hpa: Permission denied
- find: cannot chdir to /tmp/lunde: Permission denied
- find: cannot chdir to /tmp/jmaltzen: Permission denied
- find: cannot chdir to /tmp/triona: Permission denied
- < /bin/rm ... /tmp/navarra >? < /bin/rm ... /tmp/navarra/chapters >? <
- /bin/
- rm ... /tmp/navarra/nutshell >? < /bin/rm ... /tmp/navarra/vi >? <
- /bin/rm .
-
- So, they lied! Those bastards!
-
- Well, I know in this circumstance I can use:
-
- find /tmp -user navarra -exec /bin/rm -i 2>/dev/null
-
- but, really, this is not always going to help me and I was wondering
- if this problem with find is well known and if anyone has done anything
- about it? I tested this on a number of machines (Sun, Next, Sequent
- Risc) and they all didn't work.
-
- Ideas, suggestions, comments?
- -tms
- --
- You can get further with a kind word | You can get further with a kind word
- and a gun than a kind word alone. | and a phaser than a kind word and a gun.
- --al capone | -- John Navarra
- =======From the Lab of the MaD ScIenTIst....navarra@casbah.acns.nwu.edu========
-