🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.next.sysadmin
4 messages
4 total messages Started by Brendan T. McNichols Wed, 12 Aug 1992 18:47
Spaces in filenames
#697
Author: Brendan T. McNichols
Date: Wed, 12 Aug 1992 18:47
34 lines
1754 bytes
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?

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
Re: Spaces in filenames
#738
Author: Zenon Fortuna
Date: Thu, 13 Aug 1992 19:53
55 lines
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
Re: Spaces in filenames
#756
Author: John Robison
Date: Fri, 14 Aug 1992 19:40
40 lines
1706 bytes
Brendan T. McNichols writes
> Hi all,
> 
> # ---  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. 
>
After playing with this for a while, I got the following to work
(Although I used a slightly different command)

Instead of referencing your file to trash as $j,
try referencing it as "${j}". (Include quotes)

This works for direct commands like 
/bin/rm "${j}"

You will have to test it for find.

Regards,

John
-- 
John Robison - john@oceania.com
NeXTMail Gladly Accepted
--> What I say has absolutely nothing to do with
my employer. They don't even know I am posting. <--
Re: Spaces in filenames
#838
Author: Dennis Glatting
Date: Mon, 17 Aug 1992 13:50
67 lines
3238 bytes
In article <1992Aug12.144727.17189@newstand.syr.edu>  
mcnichol@terminator.psy.syr.edu (Brendan T. McNichols) 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?
> 
> 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

I have written a script that 'cleans' hard disks but is more elaborate  
then the one you posted.  Yes, it does handle spaces in the file names but  
doesn't handle some of the special characters such as '?'.  I'm satisfied  
with 95% for now but will eventually rewrite it in perl.

This script not only processes .NextTrash but cleans things like  
uucppublic, uucp, /tmp, and backup files.

The script is copyrighted but I can send it to you as a beta test site.   
Feedback will be required.  The 'clean' script is but one of a suite of  
sysadmin scripts I have written.  Some of the others include:  one that  
cruses through all of the NetInfo domains listing the domains and/or hosts  
under those domains -- useful for multi level domain structures (here at  
Trirex we have a four level);  another gathers all of the passwd entries  
from all of the domains and hosts and submits them to Crack.

We're considering marketing those scripts.  They cost money to develop.   
On the other hand, we might dump them into the public domain for education  
institution use only.  Decisions, decisions...


--
Dennis P. Glatting
Sr. Technical Manager
Trirex Systems Inc.
315 Post Road West
Westport, Connecticut   06880
203-221-4614
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads