current date modified file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting current date modified file
# 1  
Old 07-19-2012
Bug current date modified file

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 08:39 AM.. Reason: Code tags...
# 2  
Old 07-19-2012
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

# 3  
Old 07-19-2012
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  
Old 07-19-2012
touch modifies the file's timestamp.
Look here

UNIX man pages : touch ()
# 5  
Old 07-19-2012
Please post what Operating System and version you have. Do you have the GNU date command?

There is a FAQ on dates here:
https://www.unix.com/answers-frequent...rithmetic.html
# 6  
Old 07-19-2012
HI ,

My os is sun solaris 10 64 bit.
# 7  
Old 07-19-2012
We guess that you don't have the GNU date command, therefore please refer to the FAQ for date arithmetic.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Replace date in file every day with current date

I Have text like XXX_20190908.csv.gz need to replace Only date in this format with current date every day Thanks! (1 Reply)
Discussion started by: yamasani1991
1 Replies

2. UNIX for Beginners Questions & Answers

“sed” replace date in text file with current date

We want to call a parameter file (.txt) where my application read dynamic values when the job is triggered, one of such values are below: abc.txt ------------------ Code: line1 line2 line3 $$EDWS_DATE_INSERT=08-27-2019 line4 $$EDWS_PREV_DATE_INSERT=08-26-2019 I am trying to write a... (3 Replies)
Discussion started by: pradeepp
3 Replies

3. Shell Programming and Scripting

Subtract a file's modification date with current date

SunOS -s 5.10 Generic_147440-04 sun4u sparc SUNW,SPARC-Enterprise Hi, In a folder, there are files. I have a script which reads the current date and subtract the modification date of each file. How do I achieve this? Regards, Joe (2 Replies)
Discussion started by: roshanbi
2 Replies

4. OS X (Apple)

Arrange file by modified date

Hi, Am performing a find based on filename and result can contain multiple files being found Let's say my find command is find /Archive -f -name 12345.pdf and result of find command is /Archive/Folder A/12345.pdf /Archive/Folder B/12345.pdf please note white space in folder names I... (2 Replies)
Discussion started by: gigagigosu
2 Replies

5. AIX

How do I display a file's last modified date?

I'm using a script that I need to get a file's "last modified date" in a format like 01:51:14 PM. We are running on AIX 6.1.0.0. I can't seem to find the right command parameters. Help! (4 Replies)
Discussion started by: mattadams1983
4 Replies

6. Shell Programming and Scripting

How to find all files modified from midnight (i.e. from midnight (00:00:00)) of current date?

Hi there! I was wondering if someone could help me with the following: I'm trying to find all files within a directory which have been modified since midnight of the current date. Any help would be appreciated. Thank you kindly. (6 Replies)
Discussion started by: Jimmy_the_tulip
6 Replies

7. UNIX for Dummies Questions & Answers

Delete a row from a file if one column containing a date is greater than the current system date

Hello gurus, I am hoping someone can help me with the required code/script to make this work. I have the following file with records starting at line 4: NETW~US60~000000000013220694~002~~IT~USD~2.24~20110201~99991231~01~01~20101104~... (4 Replies)
Discussion started by: chumsky
4 Replies

8. UNIX for Advanced & Expert Users

Finding the modified date time of a file

Hi, I am new bie to Unix. Might be a simple question I am asking. I want to find the last modified time of a file and find the difference between the currrent time and the last modified time. Appreciate, if someone can throw some light on what commands can be used. Cheers, James (2 Replies)
Discussion started by: JamesJoe
2 Replies

9. Shell Programming and Scripting

Perl: Extracting date from file name and comparing with current date

I need to extract the date part from the file name (20080221 in this ex) and compare it with the current date and delete it, if it is a past date. $file = exp_ABCD4_T-2584780_upto_20080221.dmp.Z really appreciate any help. thanks mkneni (4 Replies)
Discussion started by: MKNENI
4 Replies

10. UNIX for Dummies Questions & Answers

How do I get the last modified date of a file?

I am trying to load a group of files and their last dates modified into a text file that will in turn be used with SQL*Loader to load these files into Oracle. I am using a *.ksh script. I am getting the name of the file in by using the following: for file_ext in 'cat loaddir.ext'; do find... (2 Replies)
Discussion started by: akpopa
2 Replies
Login or Register to Ask a Question