List the files of previous day


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers List the files of previous day
# 8  
Old 08-01-2012
Quote:
Originally Posted by RudiC
If you don't need awk, try this:
Code:
find . -daystart -mtime -2 ! -mtime -1 -ls

Will work in leap years and on month's first...
this is not working in unix.

---------- Post updated at 01:31 PM ---------- Previous update was at 01:25 PM ----------

Thanks Cragun for the reply.
But, after reading your post i believe it will be a lengthy code as i will have care of the 1st day of a month, leap year and dealing with month in text format.

Is there any simpler way to list previous day files. RudiC suggested using find but it's not working out.
# 9  
Old 08-01-2012
What does not work in your unix? If your find lacks the -daystart option, try
Code:
touch -d'today 0:0' tmp1; touch -d'yesterday 0:0' tmp2; find . -newer tmp2 ! -newer tmp1 -ls; ...; rm tmp[12]

# 10  
Old 08-01-2012
Quote:
find . -mtime -1 -name "SystemOut_*"
The above is doing fine for me.
# 11  
Old 08-01-2012
Very well!
But this will find the files that were modified between now and now-24h, not 'last day's' files which would be between 'today midnight' and 'yesterday midnight'. If the former is what you need - brilliant!

Last edited by RudiC; 08-02-2012 at 12:07 PM..
# 12  
Old 08-02-2012
Although, i need the files between 'today midnight' and 'yesterday midnight' but in my case the file i want gets updated very frequently every day.So, my problem is getting resolved by using that command.

But you are right, what i am doing is wrong and i trying to do that by doing some modification in
Quote:
d=$(date | nawk '{ print $2,$3-1}')
ls -lrt SystemOut* | nawk -v d="${d}" '$0 ~ d {print $NF}'
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find list of files modified for a given day ?

find list of files modified for a given day ? if i have 10 files in my directory, i have modified only 5 ... how to display only modified files ? (1 Reply)
Discussion started by: only4satish
1 Replies

2. UNIX for Dummies Questions & Answers

Move the files between Current day & a previous day

Hi All, I have a requirement where I need to first capture the current day & move all the files from a particular directory based on a previous day. i.e move all the files from one directory to another based on current day & a previous day. Here is what I am trying, but it gives me errors.... (2 Replies)
Discussion started by: dsfreddie
2 Replies

3. Shell Programming and Scripting

Command to list current day files only

Hi All, can anyone pls share the command to list the files of current day only. i want to check if there are any files in a particular directory which are not of current date. (6 Replies)
Discussion started by: josephroyal
6 Replies

4. Shell Programming and Scripting

Script to check if last modified day is previous day

Hi, I would like to write a script that checks if a file ('counter') was modified the previous day, if so erase its contents and write 00000000 into it. For e.g. if the file 'counter' was last modified at 11.30pm on 24th May and the script runs at 12.15am of 25th May, it should erase it's... (1 Reply)
Discussion started by: hegdepras
1 Replies

5. Shell Programming and Scripting

getting previous day.

Hi, i am developing a script for my project. In my script i need to check some conditions based upon some values. in that one value is the previous date. with the previous date i need to check and process some values. I have a function with me retrieve the yesterdays date. But now i have a... (6 Replies)
Discussion started by: intiraju
6 Replies

6. Shell Programming and Scripting

Script to find previous month last day minus one day timestamp

Hi All, I need to find the previous month last day minus one day, using shell script. Can you guys help me to do this. My Requirment is as below: Input for me will be 2000909(YYYYMM) I need the previous months last day minus 1 day timestamp. That is i need 2000908 months last day minus ... (3 Replies)
Discussion started by: girish.raos
3 Replies

7. UNIX for Dummies Questions & Answers

sample script to archive & move previous day syslog files

hi all. Please help me with archiving previous day syslog files. the files have no extension and have the format YYYY-MM-DD. I want to archive the file then move it to some other machine. thanks. (2 Replies)
Discussion started by: coolatt
2 Replies

8. Shell Programming and Scripting

Download previous day files through FTP

Hi All, I have a scenario where I need to download the previous day modified files from other server to my server through FTP . Could any one please send me the shell script for the same. I used the following but I dont know how to proceed after this. ftp -n -i -v $IP <<ENDOFinPUT >>... (3 Replies)
Discussion started by: sarathchandrach
3 Replies

9. Shell Programming and Scripting

last working day of previous month

Hi, I want a script(ksh) to see if today is the last working day(Mon-Fri) of the month. If it is the last working day I need to print current date, else I need the last working day of previous month. Thanks in advance. (1 Reply)
Discussion started by: rspk_praveen
1 Replies

10. Shell Programming and Scripting

next/Previous business day

Hello, Can you please help me how do i get previous and next working day of the week for a given date excluding saturday and sunday. Ex: if the given date is monday, i should get friday and tuesday's date if the given date is friday, i should get thrusday and monday's date. Thanks,... (4 Replies)
Discussion started by: kotasateesh
4 Replies
Login or Register to Ask a Question