Hi Expert,
I am new to UNIX , I am looking for a script which can show me list of file created on previous date within specified directory.
Regards,
Mack
Hi Expert,
I am new to UNIX , I am looking for a script which can show me list of file created on previous date within specified directory.
Regards,
Mack
# min=$(date +%M); currtime=$(($(date +%k)*60 + ${min#0*} )); find . -mmin -$((currtime + (24 * 60))) -a -mmin +$((${currtime} +
1)) | xargs ls -lrt
Thanks Sathyaonnuix,but its not working for me. Could you please verify the same?
Mackjack, can you please share your result screen.
# sh test5.sh
date: bad format character - k
test5.sh: *60 + 40 : syntax error
Can you please trying replacing k with H, also please provide the Unix you using.
you can do that by :
uname -a
HP-UX KEPSBGNO B.11.31 U ia64 2041722302 unlimited-user license
the script is running with replacing k with H
But with one : bad option -mmin error
# sh test5.sh
find: bad option -mmin
total 656
-rw-r--r-- 1 root sys 57 Aug 8 11:02 Multi-line.log
-rw-r--r-- 1 root sys 393 Aug 16 19:59 APPLMON06.bat
-rw-r--r-- 1 root sys 11 Aug 25 22:01 APPLMON06_Aug-26-2012_00:00:00.txt
-rwxrwxrwx 1 root sys 323 Aug 25 22:39 APPLMON06.sh
-r--r-xr-x 1 root sys 31 Aug 25 22:44 APPLMON06_Aug-25-2012_00:00:00.txt
-rw-r--r-- 1 root sys 11 Aug 28 03:39 APPLMON06_Aug-31-2012_00:00:00.txt
-rwxrwxrwx 1 root sys 385 Aug 28 04:18 APPLMON04-new.sh
---------- Post updated at 09:13 AM ---------- Previous update was at 09:09 AM ----------
also not listing file on previous date only. listing all files
find using -newer
option:
beg=$( perl -e 'use POSIX;print strftime "%Y%m%d0000",localtime time-86400;' )
end=$( perl -e 'use POSIX;print strftime "%Y%m%d2359",localtime time-86400;' )
touch -t $beg /tmp/beg
touch -t $end /tmp/end
find . -type f -newer /tmp/beg ! -newer /tmp/end -exec ls -l {} \;
rm -f /tmp/beg /tmp/end
Missed to add,require only the file which got created on previous day only.
This is sample of ls -lrt from the directory , and interested to have the file of previous day (i.e only 3 Jan 2013)
rw-r--r-- 1 ussd ussd 185195517 Dec 31 00:02 ussdgw_20121231.tgz
-rw-r--r-- 1 ussd ussd 185195519 Jan 1 00:02 ussdgw_20130101.tgz
-rw-r--r-- 1 ussd ussd 185195517 Jan 2 00:02 ussdgw_20130102.tgz
-rw-r--r-- 1 ussd ussd 185195516 Jan 3 00:02 ussdgw_20130103.tgz
-rw-r--r-- 1 ussd ussd 185194626 Jan 4 00:02 ussdgw_20130104.tgz
YEST=$(TZ="GMT+24" date +'%Y%m%d')
ls -lrt *${YEST}