find /tmp -atime +1 | rm does not delete my old tmp files :-(

find /tmp -atime +1 | rm does not delete my old tmp files :-(

Post by Robert Brockw » Fri, 08 Sep 1995 04:00:00



I would like to delete all files in /tmp that have not been accessed in
one day, so i tried this (as root):
        find /tmp -atime +1 | rm
This fails with:
        rm: too few arguments
        Try `rm --help' for more information.
find /tmp -atime +1 does indeed give me a list of files not accessed in 24
hours.
I have tried alot of variations and have tried to use the -exec option of
find, all to no avail.  Please help me to automate the deletion of all tmp
files as i know that it can be done.
As rm receices input from stdin i thought that a redirect would not be a
problem, but it is.
I am using Linux with Gnu find and Gnu rm.
I have RTFM, and can't find anything on this.
TIA for any help,
        -Robert


                     WWW: http://student.uq.edu.au/~ec531667

 
 
 

find /tmp -atime +1 | rm does not delete my old tmp files :-(

Post by Sally Woolric » Fri, 08 Sep 1995 04:00:00




Quote:> I would like to delete all files in /tmp that have not been accessed in
> one day, so i tried this (as root):
>         find /tmp -atime +1 | rm
> This fails with:
>         rm: too few arguments

Try

        find /tmp -atime +1 -exec rm {} \;

Or use the '-print' in your command.

--
============================================================================
Sally Woolrich                    |          This mail contains my personal

============================================================================

 
 
 

find /tmp -atime +1 | rm does not delete my old tmp files :-(

Post by Tony Curt » Fri, 08 Sep 1995 04:00:00


Robert> I would like to delete all files in /tmp that have
Robert> not been accessed in one day, so i tried this (as
Robert> root): find /tmp -atime +1 | rm This fails with: rm:
Robert> too few arguments Try `rm --help' for more

man xargs

    find /tmp -atime +1 -print | xargs rm

Or use backticks as someone else pointed out.

tony

 
 
 

find /tmp -atime +1 | rm does not delete my old tmp files :-(

Post by Robert Brockw » Fri, 08 Sep 1995 04:00:00


The answer came via email within an hour.  The answer for those interrested
is this:
        find /tmp -atime +1 | xargs rm
        -Robert


                     WWW: http://student.uq.edu.au/~ec531667

 
 
 

find /tmp -atime +1 | rm does not delete my old tmp files :-(

Post by Kevi » Sun, 10 Sep 1995 04:00:00



> I would like to delete all files in /tmp that have not been accessed in
> one day, so i tried this (as root):
>    find /tmp -atime +1 | rm
> This fails with:
>    rm: too few arguments
>    Try `rm --help' for more information.

Hmm.. strange things happen when you don't give it enough arguments :)

Quote:> find /tmp -atime +1 does indeed give me a list of files not accessed in
> 24 hours.  I have tried alot of variations and have tried to use the
> -exec option of find, all to no avail.  Please help me to automate the
> deletion of all tmp files as i know that it can be done.

find /tmp -atime +1 -exec rm -f {} \;

Quote:> As rm receices input from stdin i thought that a redirect would not be a
> problem, but it is.

rm does not read from stdin.. when was the last time you typed 'rm' and
then typd out a list of files?

Quote:>    -Robert

-kevin-


  http://www.winternet.com/~kbrint/
  winternet staff - email for info