Finding files newer than n minutes

Finding files newer than n minutes

Post by Dag Hasvol » Sun, 11 Jan 1998 04:00:00



Hi,

I thought it would be easy to use the 'find' command to get files that
was newer than n minutes. It turned out that this wasn't so easy.

I wish to find all files and directoryes newer than one week and pipe it
into a tar archive. Someone got an example of how this could be done?

Best Regards,

---------------------  http://www.intervett.no/  --------------------

------------- Intervett AS, Gjerdrumsvei 12, 0486 Oslo --------------
----------  Phone: +47 22-02-18-50, Fax: +47 22-02-18-51 ------------

 
 
 

Finding files newer than n minutes

Post by Waclaw Laszkiewic » Mon, 12 Jan 1998 04:00:00



> Hi,

> I thought it would be easy to use the 'find' command to get files that
> was newer than n minutes. It turned out that this wasn't so easy.

> I wish to find all files and directoryes newer than one week and pipe it
> into a tar archive. Someone got an example of how this could be done?

> Best Regards,

> ---------------------  http://www.intervett.no/  --------------------

> ------------- Intervett AS, Gjerdrumsvei 12, 0486 Oslo --------------
> ----------  Phone: +47 22-02-18-50, Fax: +47 22-02-18-51 ------------

Easy way to do it is to tell "find" the timeby using "-newer file" option.

###
#!/bin/sh
# time format: [CCYY]MMDDhhmm
#example: 01040455 --> Jan 04 04:55 (see man page for "touch")

echo "enter the time ( [CCYY]MMDDhhmm):  \c"
read btime
touch -am -t $btime foo_file
find . -newer foo_file -print | tar -cvf  /dev/rmt/0
rm foo_file

# Solaris "tape_special" as an example.
###

 
 
 

Finding files newer than n minutes

Post by Waclaw Laszkiewic » Mon, 12 Jan 1998 04:00:00




> > Hi,

> > I thought it would be easy to use the 'find' command to get files that
> > was newer than n minutes. It turned out that this wasn't so easy.

> > I wish to find all files and directoryes newer than one week and pipe it
> > into a tar archive. Someone got an example of how this could be done?

> > Best Regards,

> > ---------------------  http://www.intervett.no/  --------------------

> > ------------- Intervett AS, Gjerdrumsvei 12, 0486 Oslo --------------
> > ----------  Phone: +47 22-02-18-50, Fax: +47 22-02-18-51 ------------

> Easy way to do it is to tell "find" the time by using "-newer file" option.

> ###
> #!/bin/sh
> # time format: [CCYY]MMDDhhmm
> #example: 01040455 --> Jan 04 04:55 (see man page for "touch")

> echo "enter the time ( [CCYY]MMDDhhmm):  \c"
> read btime
> touch -am -t $btime foo_file
> find . -newer foo_file -print | tar -cvf  /dev/rmt/0
> rm foo_file

> # Solaris "tape_special" as an example.
> ###

Ooops!

Can't use "tar" like this:

find . -newer foo_file -print | tar -cvf /dev/rmt/0

but this should work:

find . -newer foo_file -print > temp_list    #create a temp file list for
later processing
c=`cat temp_list | wc -l`
if [ $c -ne 0 ]
    file_name=`cat temp_list | head -$c | tail -1`
    tar -uf /dev/rmt/0 $file_name
    c=`expr $c -1`
fi
rm foo_file
rm temp_list 2>/dev/null

 
 
 

1. find files newer than a process's start time?

Is this the way the pros find files newer than a former process's
start time, in a Linux shell script?
t=/tmp/$$ p=pppd
touch -d"$(ps -C $p -o lstart --no-heading)" $t
killall -HUP $p
sleep 44
find /var/cache/wwwoffle/prevtime*/.timestamp -newer $t -printf \
'******* %p newer than last call !!!!!!!\n'
rm $t

I don't suppose start time is in /proc.

2. shadow 960129

3. find files in a directory which are newer than 2 hours

4. cpus run cooler in openbsd at idle

5. Finding whether a file is newer than another in a shell script

6. Unlocking files?

7. find files newer than "date"

8. hda: lost interrupt. What?

9. find newer file

10. finding recent files, minutes not days

11. How to find files more than 3 minutes old?

12. Find files more than 15 minutes old.

13. finding file times in minute measurements