home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / question / 10785 < prev    next >
Encoding:
Text File  |  1992-09-08  |  3.1 KB  |  83 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!casbah.acns.nwu.edu!navarra
  3. From: navarra@casbah.acns.nwu.edu (John Navarra)
  4. Subject: More problems with find (the stderr bug)
  5. Message-ID: <1992Sep7.030046.18575@news.acns.nwu.edu>
  6. Sender: usenet@news.acns.nwu.edu (Usenet on news.acns)
  7. Organization: Northwestern University, Evanston Illinois.
  8. Date: Mon, 7 Sep 1992 03:00:46 GMT
  9. Lines: 72
  10.  
  11.  
  12. Here is an interesting little problem with the find command:
  13.  
  14. I want to remove certain files with my userid in the /tmp directory.
  15. Here is the command I tried:
  16.  
  17. [casbah:219] ~/tmp -> find /tmp -user navarra -ok /bin/rm {} \; 2>/dev/null 
  18.  
  19. This finds all the files with my userid in /tmp and prompts me in turn
  20. if I want to remove the file. Now, the problem is the redirect to 
  21. /dev/null. The rationale for doing this is so I won't see things like:
  22.  
  23. cannot change directory to blah: Permission denied.
  24.  
  25. However, when I run this command, it just hangs. At first, I thought it
  26. had something to do with the way I constructed the command. I ruled that
  27. out. Then, I thought it had something to do with my shell (bash) but I
  28. ruled that out by trying other sh-shells (remembering that redirecting
  29. stderr in csh/tcsh is real *fun* -- read stupid). So, then I figured
  30. it had something to do with my OS (SunOS) but no, that wasn't it
  31. either! 
  32.  
  33. Then it was time to look at the man page again:
  34.  
  35.     -ok command    Like -exec except that the generated  command
  36.                     is  written  on the standard output, then the
  37.                     standard input is read and the  command  exe-
  38.                     cuted only upon response y.
  39.  
  40. Now read that. It *says* it writes to standard output right?
  41.  
  42. Well:
  43. [casbah:226] ~ -> find /tmp -user navarra -ok /bin/rm {} \; 2>yeah_right
  44. n
  45. n
  46. n
  47. n
  48. screw you find!
  49. yeah whatever
  50. ^C
  51. [casbah:227] ~ -> cat yeah_right
  52. find: cannot chdir to /tmp/screens/S-jeff: Permission denied
  53. find: cannot chdir to /tmp/screens/S-triona: Permission denied
  54. < /bin/rm ... /tmp/screens/S-navarra >?   find: cannot chdir to
  55. /tmp/screens/S-j
  56. find: cannot chdir to /tmp/hpa: Permission denied
  57. find: cannot chdir to /tmp/lunde: Permission denied
  58. find: cannot chdir to /tmp/jmaltzen: Permission denied
  59. find: cannot chdir to /tmp/triona: Permission denied
  60. < /bin/rm ... /tmp/navarra >?   < /bin/rm ... /tmp/navarra/chapters >?   <
  61. /bin/
  62. rm ... /tmp/navarra/nutshell >?   < /bin/rm ... /tmp/navarra/vi >?   <
  63. /bin/rm .
  64.  
  65. So, they lied! Those bastards!
  66.  
  67. Well, I know in this circumstance I can use:
  68.  
  69. find /tmp -user navarra -exec /bin/rm -i 2>/dev/null
  70.  
  71. but, really, this is not always going to help me and I was wondering
  72. if this problem with find is well known and if anyone has done anything
  73. about it? I tested this on a number of machines (Sun, Next, Sequent 
  74. Risc) and they all didn't work.
  75.  
  76. Ideas, suggestions, comments?
  77. -tms 
  78. -- 
  79. You can get further with a kind word | You can get further with a kind word
  80. and a gun than a kind word alone.    | and a phaser than a kind word and a gun.
  81.           --al capone                |           -- John Navarra
  82. =======From the Lab of the MaD ScIenTIst....navarra@casbah.acns.nwu.edu========
  83.