Re: Deleting files older than 24 hours

From: Jerry.W (icesummit_at_sina.com)
Date: 06/13/03


Date: Fri, 13 Jun 2003 16:54:56 +0800

BTW, you will not be able to know the creation time of a file. It isn't
stored.

Jerry.W

"Tim Hammerquist" <tim@vegeta.ath.cx> wrote in message
news:slrnbej2f2.s3d.tim@vegeta.ath.cx...
> manfred.leopold@documentum.com graced us by uttering:
> > sorry but I'm just a little bit confused.
> > Seems to be a simple question, but I don't find the way.
> >
> > I'm trying to get a shell-script for doing the following:
>
> This smells of homework, but you shouldn't need a shell script
> for these in any case. Let me see:
>
> > 1. deleting all files in a specified directory
>
> You should be able to accomplish this with just the rm(1)
> command, a directory, and maybe some wildcards. See `man rm`.
>
> # absolute path
> $ rm /path/to/some/dir/*
> # relative path
> $ rm sub/ordinate/dir/*
>
> > 2. deleging all files in a specified directory which are older
> > than 24 hours.
>
> For this, you almost certainly want find(1). The syntax can be
> daunting, but find is one of the most powerful commands you can
> find on any *nix system. You could also easily use the find
> comand to accomplish task 1 above.
>
> One warning, though: you'll need to define the "age" of a file.
> Do you want files which haven't been accessed (ie, read) in over
> 24 hours? Or files which haven't been modified (ie,
> written/changed) in over 24 hours? Or files which were *created*
> over 24 hours ago? These would be specified to the find(1)
> command as atime, mtime, and ctime, respectively.
>
> Finally, the action you want find(1) to take on each file it
> finds can be piped to a second command, or passed to a command
> specified by the -exec argument.
>
> The destination would be `man find`.
>
> HTH,
> Tim Hammerquist
> --
> Remember, kids. With great power comes
> great opportunity to *abuse* that power.
> -- Black Mage, 8-bit Theatre <http://nuklearpower.com/>



Relevant Pages

  • Re: Deleting files older than 24 hours
    ... manfred.leopold@documentum.com graced us by uttering: ... comand to accomplish task 1 above. ... command as atime, mtime, and ctime, respectively. ... great opportunity to *abuse* that power. ...
    (comp.unix.questions)
  • Re: require and do - absolute vs relative - let me try again
    ... > location using an absolute path. ... I have the same problem from command line. ... turns out it is just this script. ... with a relative path (any other relative path fails as well "No such file ...
    (comp.lang.perl.misc)
  • Re: system() function and current working directory
    ... As long as 'otherpath' is an absolute path that's one of the ... possibilites - but if it's a relative path you still have the ... But why do you insist on running the command you want to ...
    (comp.unix.programmer)
  • Re: Changing the Bash/SSH prompt
    ... >> That was usefull to know, but how does it actually do it ... AFAIC understand, if that is so, is the 'export' command really necessary? ... > tilde is used as a simple replacement for the absolute path to the users ... > ~username works too and you can use it for another users home directory. ...
    (alt.linux)
  • Re: access tex files across directories
    ... khandelwal.amitk@xxxxxxxxx schrieb: ... > I have a main.tex file which I want to input other tex files in ... You can also use command like ...
    (comp.text.tex)