Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 07-06-2012
Registered User
 
Join Date: Apr 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Error How to count previous days files

Hi i know how to get no of files in some particular folder by following command which includes today and previous days files also

Code:
ls |wc -l

but i needed a command in which i can list previous one or two days files only.

Last edited by radoulov; 07-06-2012 at 08:58 AM..
Sponsored Links
    #2  
Old 07-06-2012
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
 
Join Date: Sep 2005
Location: Switzerland - GE
Posts: 4,633
Thanks: 118
Thanked 256 Times in 245 Posts
I dont think you have much choice... you will have to use the find command...
Sponsored Links
    #3  
Old 07-06-2012
Registered User
 
Join Date: Apr 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
how can find be helpful in this case?
    #4  
Old 07-06-2012
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
 
Join Date: Sep 2005
Location: Switzerland - GE
Posts: 4,633
Thanks: 118
Thanked 256 Times in 245 Posts
If you only want to use ls, then you are to use ls -l anda pipe with grep the pattern being the date.. (and a extra pipe for wc -l
Sponsored Links
    #5  
Old 07-06-2012
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
 
Join Date: Sep 2005
Location: Switzerland - GE
Posts: 4,633
Thanks: 118
Thanked 256 Times in 245 Posts

Code:
ran:/home/vbe $ ls -l|grep " Jun 1[12] "
-rw-rw-rw-   1 vbe        bin           4192 Jun 11 18:12 net_pb.out
-rw-------   1 vbe        bin            372 Jun 12 20:09 nohup.out
ran:/home/vbe $ ls -l|grep " Jun 1[12] "|wc -l
3

Possible issue with this approach you will not have with find:

Code:
ran:/home/vbe $ ls -l|grep " Jun 1[12] "
-rw-rw-rw-   1 vbe        bin            367 Jun 12  2009 dsk_todo.090526
-rw-rw-rw-   1 vbe        bin           4192 Jun 11 18:12 net_pb.out
-rw-------   1 vbe        bin            372 Jun 12 20:09 nohup.out

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need Help in reading N days files from a Directory & combining the files dsfreddie UNIX for Dummies Questions & Answers 1 12-30-2011 11:33 AM
Append Previous Days date to filename Twisha UNIX for Dummies Questions & Answers 2 09-02-2010 12:20 AM
Number of days in the previous month lyoncc Shell Programming and Scripting 11 08-10-2010 01:52 PM
using 'date' to get previous days' dates slant-40 UNIX for Dummies Questions & Answers 2 06-17-2008 08:49 PM
ls latest 4 days or specify days of files in the directory happyv Shell Programming and Scripting 3 01-22-2007 06:16 AM



All times are GMT -4. The time now is 05:58 PM.