Article View: comp.sys.next.sysadmin
Article #738Re: Spaces in filenames
From: Zenon Fortuna
Date: Thu, 13 Aug 1992 19:53
Date: Thu, 13 Aug 1992 19:53
55 lines
2634 bytes
2634 bytes
In article <1992Aug12.144727.17189@newstand.syr.edu> mcnichol@mailbox.syr.edu writes:
>Hi all,
>
>I have the following script which I modified from an earlier post by Jim
>Kiraly to search through the entire filesystem and delete all old files
>in .NextTrash directories.
>
># --- Empty the Recycler(s) --- Changed by Brendan on August 10, 1992
># from an earlier version posted by Jim Kiraly to comp.sys.next.sysadmin
>#
># Search through entire filesystem looking for .NextTrash directories.
># Save the list in the variable trashlist. For every .NextTrash directory
># found in the previous command, find and delete all files that are more
># than 1 day old.
>trashlist=`find / -type d -name .NextTrash -prune -print`
>for j in $trashlist
> do
> echo 'Removing files more than 1 day old from recycler: '$j
># find $j -ctime +1 -depth -exec rm -rf {};
> done
>
>Unfortunatly, the script does not work if one of the paths in the
>trashlist variable has a space in it. When the for loop gets to the path
>with the space in it, it thinks that the path is actually two paths.
>Anyone know how I would go about fixing this problem? Can anyone think
>of a better way of writing this script?
The syntax of the script suggests the Bourne-shell. If this is the case one
can tell the Shell to ignore the space in the name, i.e. do not treat it as
name separator.
The IFS parameter tells the Bourne-shell which characters use to separate names
(IFS means: internal field separators), so before the "for j in $trashlist"
line, one can insert the declaration :
IFS="
"
(i.e. IFS string, equal sign, double quote, return, and double quote again)
This will tell the Shell to take all names from the trashlist up to the
new line sign.
The manual for sh(1) informs, that IFS is ignored for root, and when the
effective user is different from the real one. I have checked for root and
it still works.
Manual bug ? :-)
-Z.
>
>Thanks very much in advance,
>Brendan
>
>--
>Brendan T. McNichols, Computer Support (315) 443-9577
>Psyracuse U. Sychology Dept. mcnichol@psy.syr.edu (NeXT)
>430 Huntington Hall mcnichol@syr.edu
>Syracuse, NY 13244
Technical Details
Message-ID:
<1992Aug13.195334.20546@resonex.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!decwrl!netcomsv!resonex!zenonReferences:
<1992Aug12.144727.17189@newstand.syr.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.next.sysadmin Path: arc1-ca.pugleaf.net!sparky!uunet!decwrl!netcomsv!resonex!zenon From: zenon@resonex.com (Zenon Fortuna) Subject: Re: Spaces in filenames Message-ID: <1992Aug13.195334.20546@resonex.com> Organization: Resonex Inc., Sunnyvale CA References: <1992Aug12.144727.17189@newstand.syr.edu> Date: Thu, 13 Aug 1992 19:53:34 GMT Lines: 57