home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / next / sysadmin / 4653 < prev    next >
Encoding:
Text File  |  1992-08-13  |  2.5 KB  |  68 lines

  1. Newsgroups: comp.sys.next.sysadmin
  2. Path: sparky!uunet!decwrl!netcomsv!resonex!zenon
  3. From: zenon@resonex.com (Zenon Fortuna)
  4. Subject: Re: Spaces in filenames
  5. Message-ID: <1992Aug13.195334.20546@resonex.com>
  6. Organization: Resonex Inc., Sunnyvale CA
  7. References: <1992Aug12.144727.17189@newstand.syr.edu>
  8. Date: Thu, 13 Aug 1992 19:53:34 GMT
  9. Lines: 57
  10.  
  11. In article <1992Aug12.144727.17189@newstand.syr.edu> mcnichol@mailbox.syr.edu writes:
  12. >Hi all,
  13. >
  14. >I have the following script which I modified from an earlier post by Jim  
  15. >Kiraly to search through the entire filesystem and delete all old files  
  16. >in .NextTrash directories.  
  17. >
  18. ># ---  Empty the Recycler(s)   --- Changed by Brendan on August 10, 1992
  19. ># from an earlier version posted by Jim Kiraly to comp.sys.next.sysadmin 
  20. >#
  21. ># Search through entire filesystem looking for .NextTrash directories.
  22. ># Save the list in the variable trashlist. For every .NextTrash directory 
  23. ># found in the previous command, find and delete all files that are more 
  24. ># than 1 day old.
  25. >trashlist=`find / -type d -name .NextTrash -prune -print`
  26. >for j in $trashlist 
  27. >  do
  28. >    echo 'Removing files more than 1 day old from recycler: '$j
  29. >#    find $j -ctime +1 -depth -exec rm -rf {};
  30. >  done
  31. >
  32. >Unfortunatly, the script does not work if one of the paths in the  
  33. >trashlist variable has a space in it.  When the for loop gets to the path  
  34. >with the space in it, it thinks that the path is actually two paths.   
  35. >Anyone know how I would go about fixing this problem?  Can anyone think  
  36. >of a better way of writing this script?
  37.  
  38. The syntax of the script suggests the Bourne-shell. If this is the case one
  39. can tell the Shell to ignore the space in the name, i.e. do not treat it as
  40. name separator.
  41.  
  42. The IFS parameter tells the Bourne-shell which characters use to separate names
  43. (IFS means: internal field separators), so before the "for j in $trashlist"
  44. line, one can insert the declaration :
  45. IFS="
  46. "
  47. (i.e. IFS string, equal sign, double quote, return, and double quote again)
  48. This will tell the Shell to take all names from the trashlist up to the
  49. new line sign.
  50.  
  51. The manual for sh(1) informs, that IFS is ignored for root, and when the
  52. effective user is different from the real one. I have checked for root and
  53. it still works.
  54. Manual bug ?  :-)
  55.  
  56.     -Z.
  57. >
  58. >Thanks very much in advance,
  59. >Brendan
  60. >
  61. >--
  62. >Brendan T. McNichols, Computer Support                (315) 443-9577
  63. >Psyracuse U. Sychology Dept.             mcnichol@psy.syr.edu (NeXT)
  64. >430 Huntington Hall                                 mcnichol@syr.edu
  65. >Syracuse, NY 13244
  66.  
  67.  
  68.