How to list todays file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to list todays file
# 15  
Old 07-17-2009
Quote:
thanks for the codes, its working fine but i need a command line.
Can you be more specific.
# 16  
Old 07-17-2009
HI friend,

now i am getting the error variable syntax for bothe command liners.

*not sure if there is any way to get a 1 liner to list todays file

---------- Post updated at 09:07 PM ---------- Previous update was at 09:06 PM ----------

Hi Methyl,

I have used your code and its working fine.
But I need a 1 liner which I am not able to work out.

---------- Post updated at 09:10 PM ---------- Previous update was at 09:07 PM ----------

i want to execute a one line command which will list all files of a particular pattern with todays date.
The same pattern files may be present for yesterday also but the command will list only file with current date (todays date)
# 17  
Old 07-17-2009
What do you want the output to look like?
# 18  
Old 07-17-2009
only the file names would do
# 19  
Old 07-17-2009
Fair attempt at a one-liner. Does not work for filenames containing space characters but does avoid calling "date" for each filename.

Code:
TODAY="`date +'%b %e'`";find `pwd` -type f -name "esi01v*" -mtime -1 -exec ls -lad "{}" \; | grep " ${TODAY} "|awk '{print $9}'


Last edited by methyl; 07-17-2009 at 01:15 PM.. Reason: Bad paste
# 20  
Old 07-18-2009
What we can do is to "touch" a file that is created today at 00:00:00 and we can use shell to compare those files newer than this file
Code:
touch -t 200907180000 /tmp/today.file
for i in `find . -type f`
do
    if [ $i -nt /tmp/today.file ]; then
        echo $i
    fi
done

BTW, the "-nt" newer only available in ksh and bash

---------- Post updated at 11:29 PM ---------- Previous update was at 10:13 PM ----------

Sorry, we need to make it more generic
Code:
touch -t `date '+%Y%m%d0000'` /tmp/today.file
for i in `find . -type f`
do
    if [ $i -nt /tmp/today.file ]; then
        echo $i
    fi
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to list todays file in perticular folder?

How to list todays file in perticular folder Moved thread to appropriate forum (9 Replies)
Discussion started by: pspriyanka
9 Replies

2. UNIX for Dummies Questions & Answers

Help in script to check file name with todays date

I am trying to include a snippet in my script to check if the file created is having today's date. eg: File name is : ABC.YYYYMMDD-nnn.log The script should check if 'YYYYMMDD' in the above file name matches with today's date. Can you please help me in achieving this. Thanks in advance!! (5 Replies)
Discussion started by: kiran1112
5 Replies

3. Shell Programming and Scripting

Count for only todays files.

Hi, I unable to find the direct command get the total count for the below files with today date. ls -lrt c90.txt n5.txt t1.txt k3.txt h9.txt s1.txt n2.txt a123.txt -rw-rw-r-- kkk klkl 980 Apr 26 19:00 c90.txt -rw-rw-r-- kkk klkl 80 Apr 26 19:00 n5.txt -rw-rw-r-- kkk klkl 12890 Apr 26... (3 Replies)
Discussion started by: onesuri
3 Replies

4. Shell Programming and Scripting

How to list todays and yesterdays .rej files from a directory?

I am trying to display todays and yesterdays .rej files from a directory. ls -lrt *.rej | grep 'Aug 12' ; ls -lrt *.rej | grep 'Aug 13' Which is working as above. But i want take 'Aug 12' and 'Aug 13' from a variable and the command should work everyday. I am able to get todays files by... (9 Replies)
Discussion started by: GopalKrishnaP
9 Replies

5. Shell Programming and Scripting

how to get todays file name

Hi ! there can you please tell me how to get full files having today date like if i have files like this(below) , i want to grep only sra + today's date + what ever thing is there after date . grep `sra*$date*.csv` >>> i tried this one but its not working . sra28-08-2011xyz.csv... (1 Reply)
Discussion started by: sravan008
1 Replies

6. UNIX for Dummies Questions & Answers

need to zip all the files excluding todays file

HI All, At present in my server the log folder was filled up and causing memory issue. So I am planning to write a script in such a way that the files which are older than 30 days will be deleted and also need to find the files which were not compressed and need to compress this file.... (4 Replies)
Discussion started by: arumilli
4 Replies

7. Shell Programming and Scripting

List/Range Todays Log.

Hi All, I am mediator Shell programmer, Just have an hands on experice :-), i am writing a shell scirpt to list logs of todays date from /var/log/messages. I need to ur kind help where if i run this script from cron. the script should filter todays logs only from /var/log/messages. Below... (4 Replies)
Discussion started by: anand.kulkarni
4 Replies

8. Shell Programming and Scripting

How to grep a string in todays file

Hello guys - I am new to Unix. I am trying to understand how to grep a perticular string in todays file? I am trying this syntax but not getting what I am looking for: % grep `date '+%d/%b/%Y'` For instance there are 2 files generated today with same data. I am trying to find them and... (21 Replies)
Discussion started by: DallasT
21 Replies

9. Linux

Comparing the file drop date with todays date

Daily one file will dropped into this directory. Directory: /opt/app/jt/drop File name: XXXX_<timestamp>.dat.gz I need to write a script which checks whether the file is dropped daily or not. Any idea in the script how can we compare timestamp of the file to today's date?? (3 Replies)
Discussion started by: Rajneel
3 Replies

10. Shell Programming and Scripting

want to delete timestamp from todays file

i want to delete the time stamp from the file which have a date of yester day 640878 Nov 6 09:08 fbres.01.20031106:09:08:30 here is what my ls -lt command shows in current directory it want it to be 640878 Nov 6 09:08 fbres.01.20031106 thanks (5 Replies)
Discussion started by: maverick
5 Replies
Login or Register to Ask a Question