how to delete files with shell script

  • Follow


hello everyone..
i have to delete files on my homedir which are more than three days
old...im not able to figure out how to do this with a shell script..i
do know that this can be done with `ls -l -t` and tr, cut, ..but im not
able to combine all of them and write a shell script...
i use /bin/bash shell

thanks
danish

0
Reply me.linuxadmin (191) 2/1/2006 4:57:25 AM

On 2006-02-01, linuxadmin <me.linuxadmin@gmail.com> wrote:
> i have to delete files on my homedir which are more than three days
> old...im not able to figure out how to do this with a shell script..i
> do know that this can be done with `ls -l -t` and tr, cut, ..but im not
> able to combine all of them and write a shell script...

man find, look for the mtime, atime, and ctime options.  Be sure to test
it before using it to delete files.

--keith

-- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
see X- headers for PGP signature information

0
Reply kkeller-usenet (1289) 2/1/2006 5:27:06 AM


linuxadmin <me.linuxadmin@gmail.com> wrote:
> i have to delete files on my homedir which are more than three days
> old...im not able to figure out how to do this with a shell script..i

Man find (become "able").

Peter
0
Reply ptb (2756) 2/1/2006 8:48:55 AM

"linuxadmin" <me.linuxadmin@gmail.com> writes:

> hello everyone..
> i have to delete files on my homedir which are more than three days
> old...im not able to figure out how to do this with a shell script..i

find /home/al/yum_repo -mtime -26 > repopatch26day.txt

There's one (a command) I used the other day.

I think it finds "since last modified time" of less than 26 days.

I don't know if this will work for me.

I run rsync once a week against an internet yum repository (sync my
local repository with the internet repository)

In order to mail a CD of updates to a friend, I need to get the
difference that has happened within my own local repository in the
last 26 days.

It is these files from this difference that I need to get copied
to CD disk.

And I'm not sure the above command

suggestions/ideas?

-- 
Alan.
0
Reply mtbr1119AT (8) 2/1/2006 8:57:20 AM

3 Replies
46 Views

(page loaded in 0.084 seconds)

Similiar Articles:













7/24/2012 1:34:25 PM


Reply: