how to list all the files for today in the dir


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to list all the files for today in the dir
# 8  
Old 12-02-2011
Code:
 
find . -type f -mtime -1 -maxdepth 1

# 9  
Old 12-02-2011
i am using sh shell

---------- Post updated at 05:57 AM ---------- Previous update was at 05:55 AM ----------

maxdepth does not work for me Smilie
find . -type f -mtime -1 -maxdepth 1
find: bad option -maxdepth
find: path-list predicate-list



Quote:
Originally Posted by itkamaraj
Code:
 
find . -type f -mtime -1 -maxdepth 1

# 10  
Old 12-02-2011
Code:
ls -l | perl -ne '$x=substr localtime, 4, 6; /$x/ && print $_'

# 11  
Old 12-02-2011
Quote:
Originally Posted by balajesuri
Code:
ls -l | perl -ne '$x=substr localtime, 4, 6; /$x/ && print $_'

this is displaying 2010 files also

-rw-r----- 1 ajay ajay 0 Dec 2 20:37 test11.txt
-rw-r----- 1 ajay ajay 0 Dec 2 20:32 test1.txt
-rw-r----- 1 ajay ajay 0 Dec 2 20:32 test.txt
-rw-r----- 1 ajay ajay 0 Dec 2 20:37 text12.txt
-rw-r----- 1 ajay ajay 0 Dec 2 2010 text20.txt
-rw-r----- 1 ajay ajay 0 Dec 2 2010 text21.txt
-rw-r----- 1 ajay ajay 0 Dec 2 2010 text22.txt
-rw-r----- 1 ajay ajay 0 Dec 2 2010 text23.txt

-rw-r----- 1 ajay ajay 0 Dec 2 20:32 text3.txt
-rw-r----- 1 ajay ajay 0 Dec 2 20:32 text4.txt
# 12  
Old 12-02-2011
Code:
ls -ltrh | egrep "`date | cut -c5-10`.*:"

Works for me on a SunOS 5.9 system
# 13  
Old 12-02-2011
Code:
ls -l | perl -ne '$x=substr localtime, 4, 6; /$x\s+[0-9]{2}:[0-9]{2}/ && print $_'

# 14  
Old 12-02-2011
Thanks CarloM this is working fine ...will it work at my OS always ...irrespective of if there exists 2009 , 2008 files at dir ...thanks again ,..can u please explain cut -c5-10`.*:" part
Quote:
Originally Posted by CarloM
Code:
ls -ltrh | egrep "`date | cut -c5-10`.*:"

Works for me on a SunOS 5.9 system
---------- Post updated at 06:16 AM ---------- Previous update was at 06:09 AM ----------

CarloM,
One more help required ..if there is no file found for today then I would like to display
"No files for today" ...how to check that condition...
Quote:
Originally Posted by CarloM
Code:
ls -ltrh | egrep "`date | cut -c5-10`.*:"

Works for me on a SunOS 5.9 system
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

List files in dir and grep accordingly

bash or c-shell On Solaris 10 I need a command that will list the files of a directory, and grep each of those filenames out of a static text file, and then only echo field 2 of the static text file. Something like this: #> ls -1 /home/dir/ | each filename grep $filename static.txt |awk... (4 Replies)
Discussion started by: ajp7701
4 Replies

2. Linux

List all files created today exclude last one

Hi, ALL thanks in advance, i listed all files using this command ls -ltr $(date +%Y%m%d)*.xmlbut i would like to exclude the last one created ; Best regard MEROUAN Use code tags, thanks. (4 Replies)
Discussion started by: merouan
4 Replies

3. Shell Programming and Scripting

Copy files to a dir using from a list

Hi all, I'd very grateful for some help with the following: I have a directory with several subdirectories with files in them. All files are named different, even between different subdirectories. I also have a list with some of those file names in a txt file (without the path, just the file... (5 Replies)
Discussion started by: foracoffee
5 Replies

4. UNIX for Dummies Questions & Answers

How to list all files in dir and sub-dir's recursively along with file size?

I am very new to unix as well as shell scripting. I have to write a script for the following requirement. In have to list all the files in directory and its sub directories along with file path and size of the file Please help me in this regard and many thanks in advance. (3 Replies)
Discussion started by: nmakkena
3 Replies

5. Shell Programming and Scripting

How to get a list of files in a dir w/o sub-directories?

Hi I am looking for the correct syntax to find all files in the current directory without listing sub-directoris. I was using the following command, but it still returns subdirectoris and files inside them: $ ls -laR | grep -v ^./ Any idea? Thanks PS I am in ksh88 (4 Replies)
Discussion started by: aoussenko
4 Replies

6. Shell Programming and Scripting

Generate a change list of files/dir

Is there a tool that can diff a directory and generate a change list of files in that directory based on a previous snapshot on the directory? For example /etc/a.txt:changed /etc/b.txt:removed /etc/c.txt:added Thanks! (1 Reply)
Discussion started by: overmindxp
1 Replies

7. Shell Programming and Scripting

How to copy specified files from list of files from dir A to dir B

Hello, fjalkdsjfkldsajflkajdskl (3 Replies)
Discussion started by: pmeesara
3 Replies

8. UNIX for Dummies Questions & Answers

To list all the files created today with directory path

Hi, Can any one tell the command to list all the files that are created as of today from all the directories? The Command "ls -ltR" is listing all the files. But I want the list of files that has been created as of today along with the directory path:) Thank you in advance.:) Regards,... (4 Replies)
Discussion started by: meetusha.b
4 Replies

9. 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

10. Shell Programming and Scripting

How to list today's files

Hi, I am trying to list names of only today's files OR say, files which are not older than 1 hour and copy them in 'list.txt' file. I know, :ls > list.txt will list all the files. But, how to list today's files? Any help will be appriciated. (4 Replies)
Discussion started by: berlin_germany
4 Replies
Login or Register to Ask a Question