|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi , In my directory , i have many days file but i want to see all those which are of todays date. i tried this but it gives all the files Code:
mtime -0 |ls -ltr I tried the below option as well. Code:
19635 find -iname "*.LOG" -mtime 19636 ls -ltr *.LOG -mtime -1 19637 ls -ltr *.LOG mtime -0 nothing worked. Can you suggest me how to list all the current days file and want to move them current day file to new directory Last edited by Scott; 07-19-2012 at 07:39 AM.. Reason: Code tags... |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
I assume you mean a calendar day, starting at midnight. The format for the date in the touch command is YYYYMMDDHHMI; the date command format string gives you midnight when run any time during the day Code:
cd /log/directory
# be sure to make the new day's directory before all this below
touch -t `date +%Y%m%d0000` dummy
find . -newer dummy -type f |
while read fname
do
mv $fname [new directory name goes here]
done |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Hi ,
Many thanks it is working. I need few clarification here , what does touch -t is doing here. scripts looks like can be run any day and it will bring the data for current day. can it be modied according to the need let say once in month if i want to move all the file for yesterday or may be 3 days back one. how can we amend here in this file. Much appreciated. Thanks Rajesh |
|
#4
|
|||
|
|||
|
|
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Please post what Operating System and version you have. Do you have the GNU
date command?
There is a FAQ on dates here: http://www.unix.com/answers-frequent...rithmetic.html |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
HI ,
My os is sun solaris 10 64 bit. |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
We guess that you don't have the GNU
date command, therefore please refer to the FAQ for date arithmetic.
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Delete a row from a file if one column containing a date is greater than the current system date | chumsky | UNIX for Dummies Questions & Answers | 4 | 07-06-2011 02:07 AM |
| Test if a file has a last modified date of within the last 24 hours | rethink | Shell Programming and Scripting | 2 | 03-17-2011 05:04 AM |
| Finding the modified date time of a file | JamesJoe | UNIX for Advanced & Expert Users | 2 | 01-30-2011 02:27 PM |
| Perl: Extracting date from file name and comparing with current date | MKNENI | Shell Programming and Scripting | 4 | 03-26-2008 04:01 PM |
| How do I get the last modified date of a file? | akpopa | UNIX for Dummies Questions & Answers | 2 | 08-29-2001 03:08 PM |
|
|