How can I get difference date between today and 15 days ago and all filename is was created before 15 days ago?
It has to be korn shell script.
Thanks.
How can I get difference date between today and 15 days ago and all filename is was created before 15 days ago?
It has to be korn shell script.
Thanks.
#!/bin/ksh
cd /PATH/to/files
touch somefile
ls -rt *.log | tail -1 | read newfile
touch_value=$(perl -e '
$mtime=(stat $ARGV[0])[9];
$mtime = $mtime - (86400*15);
($sec,$min,$hour,$mday,$mon,$year,$wday,
$yday,$isdst)
= localtime($mtime);
printf "%d%02d%02d%02d%02d\n", $year+1900, $month+1, $day+1, $hour, $min;
' $newfile )
touch -t $touch_value touchfile
find . ! -newer touchfile -print
edit - mistake - used a file not today's date
The creation time of files is not stored on *nix systems. You can use the time the file was last modified:
find . -mtime +15 -print