Files generated today


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Files generated today
# 1  
Old 12-29-2011
Files generated today

I would like to find the Files which are generated today in the current directory:

I use the commad ls -lrt * | egrep " `date "+%b"` * `date "+%d"`
to acheive this. Is there any better way to acquire the same.

Multiple answers will be great. Thanks
# 2  
Old 12-30-2011
Use find command with -mtime option.
# 3  
Old 12-30-2011
We can't find the files generated today(file creation date can be found only on ext4 filesystems), only files with today's timestamp can be found.

Code:
find . -mtime -1

Code:
ls -l | grep `date +%Y-%m-%d`

this again depends on how your ls lists the files.

HTH
--ahamed
# 4  
Old 12-30-2011
Quote:
ls -lrt * | egrep " `date "+%b"` * `date "+%d"`
This is a syntax error. There is an odd number of double quotes. Also the "%d" switch to "date" gives a day number with leading zeros.
Please post a sample "ls -l" listing so we can see what the date looks like in your "ls" listing for single and double digit days.


My crude method for directory listing where the date format is "Mmm dD" (day with leading space). The grep for a colon is a crude way of avoiding previous years. Processing a formatted directory listing is not perfect for many reasons but it will often do the job if you have simple boring filenames which do not contain colons or formatted dates.
Code:
#!/bin/ksh
TODAY="`date '+%b %e'`"        # Mmm dD
ls -lrt | grep "${TODAY}"|grep ":"

Ps. There is a much better method using find, but not with the "-mtime" switch". It involves creating a timestamp reference file with "touch" and using "find -newer".
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search files with today date and files come anytime in between 10 pm to 1 am

Hi, i want to make script. In a directory everyday( exclude sat and sun) in between 10 pm to 1 am there are 2 files comes and when file comes it will mail us. Format for files is mentioned below. please help me on making this, and also have year end consider and if files come after 12 am it... (6 Replies)
Discussion started by: pallvi_mahajan
6 Replies

2. UNIX for Advanced & Expert Users

Script to rename file that was generated today and which starts with date

hello, can someone please suggest a script to rename a file that was generated today and filename that being generated daily starts with date, its a xml file. here is example. # find . -type f -mtime -1 ./20130529_4995733057260357019.xml # this finename should be renamed to this format.... (6 Replies)
Discussion started by: bobby320
6 Replies

3. Shell Programming and Scripting

Move all files except sys date (today) files in Solaris 10

I want to move all files from one directory to another directory excluding today (sysdate files) on daily basis. file name is in pattern file_2013031801, file_2013031802 etc (2 Replies)
Discussion started by: khattak
2 Replies

4. Shell Programming and Scripting

How to pick only the files which are generated in one hour?

Hello Masters, I need one help. I want to copy the files which are continuously generating on one server. But this would be on hourly basis. e.g. -rw-rw-r-- 1 akore akore 0 Feb 12 03:20 test1.log -rw-rw-r-- 1 akore akore 0 Feb 12 03:42 test2.log -rw-rw-r-- 1 akore akore 0 Feb 12 04:22... (2 Replies)
Discussion started by: akore83
2 Replies

5. Shell Programming and Scripting

Files generated by a particular user

Hi I have the following files generated by different users on a directory -rw-rw-r-- 1 NAME1 database03 809 Nov 17 10:41 PCAS_CARD_TRANS_OFF.1111171041.lg -rw-rw-r-- 1 richard ccsdba 10968411 Nov 17 10:43 load_123_RX0_0.1111171016.lg -rw-rw-r-- 1 DEV db03 10713 Nov 17... (5 Replies)
Discussion started by: bobby1015
5 Replies

6. Solaris

core files not getting generated

Hi, We have an application ASPA . The application related processes are running in /ASPA/bin directory . now whenever a process terminates abruptly , a core file should be generated (correct me if i am wrong) in the /ASPA/bin directory . But i am not able to see any such files . The... (4 Replies)
Discussion started by: asalman.qazi
4 Replies

7. UNIX for Advanced & Expert Users

Type v for generated files

Hi All, I was checking some of the files and I got the following entries:- =============== v, 664, serv, serv, version.txt, exe L, 775, serv, serv, start.sh, eventserv ================ Could someone please tell me what does the type"v" and "L" represent to. I have not... (2 Replies)
Discussion started by: shubhranshu
2 Replies

8. UNIX for Dummies Questions & Answers

Sort files by date, not showing files from today

Hi all, i'm new here in this forum. I really like the helpful answers in this forum. Here a short question. For a script i have to sort files by date and exclude the files of the actual date. Sorting the files by date and preparing the output for awk is done by this line: ls -l... (3 Replies)
Discussion started by: carlosdivega
3 Replies

9. Shell Programming and Scripting

Ftp all the generated files

Hi All, I'm working on a ftp shell script in which I'm tranfering files from one sever to another using ftp. Some program generates files at undefined time & throughout the day. I have to transfer the files time to time.. i.e. once the file is generated, it should be transfered at the very... (3 Replies)
Discussion started by: im_new
3 Replies

10. UNIX for Dummies Questions & Answers

How to list all the files which are not generated today

How to list all the files which are not generated today, and move all the above files to backup dir. (2 Replies)
Discussion started by: redlotus72
2 Replies
Login or Register to Ask a Question