How to count previous days files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to count previous days files
# 1  
Old 07-06-2012
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 09:58 AM..
# 2  
Old 07-06-2012
I dont think you have much choice... you will have to use the find command...
# 3  
Old 07-06-2012
how can find be helpful in this case?
# 4  
Old 07-06-2012
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
# 5  
Old 07-06-2012
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

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Purge X old days files and Print count

Hello All, I am trying to purge X old days of files from directory & Sub directories ./2016-01-13/1500/abc.txt ./2016-01-14/1605/caf.txt ./2016-01-14/1605/caf2.txt ./2016-01-14/1606/eaf.txt ..... ./2017-08-1/1701/ Should also remove directories and sub directories too Expected... (7 Replies)
Discussion started by: krux_rap
7 Replies

2. Shell Programming and Scripting

Error files count while coping files from source to destination locaton as well count success full

hi All, Any one answer my requirement. I have source location src_dir="/home/oracle/arun/IRMS-CM" My Target location dest_dir="/home/oracle/arun/LiveLink/IRMS-CM/$dc/$pc/$ct" my source text files check with below example.text file content $fn "\t" $dc "\t" $pc "\t" ... (3 Replies)
Discussion started by: sravanreddy
3 Replies

3. Shell Programming and Scripting

Display previous days dates in ksh

---------- Post updated at 03:42 AM ---------- Previous update was at 03:38 AM ---------- Sorry for a duplicate post, my post at the first place could not appear due to some net issue on my machine. Here is what i posted earlier: Hi, i am using ksh in Solaris, i wanted to assign today's,... (5 Replies)
Discussion started by: pr5439
5 Replies

4. Shell Programming and Scripting

Process previous days file

Hi, i've a scenario where i need to unizp the previous day files based on the no of days given as input. EX: if my no of days are 5 i need to go to archive dir and pull last 5 days files from currentday -1 . Please help with this shell script. Regards, sandeep. (5 Replies)
Discussion started by: sandeep karna
5 Replies

5. Shell Programming and Scripting

Can i get the previous/next days date of a selected day

Ok, the title is confusing i know, but it is a weird question. I have a bash script running on Centos5.8 and want to find a better way to do some date manipulation. What i am trying to do is get 3 days of files (day before, that day, and day after), concatenate the three files and pass them on... (2 Replies)
Discussion started by: oly_r
2 Replies

6. UNIX for Dummies Questions & Answers

Finding days in previous month

#!/bin/ksh day=1 month=1 year=2012 if then then prevmonth=31 elif then prevmonth=30 elif then then prevmonth=29 elif then prevmonth=29 else prevmonth=28 fi (4 Replies)
Discussion started by: vagar11
4 Replies

7. UNIX for Dummies Questions & Answers

Append Previous Days date to filename

I need to append previous days date to my file which is generated using a script. I am working on Solaris 10. Thanks! (2 Replies)
Discussion started by: Twisha
2 Replies

8. Shell Programming and Scripting

Number of days in the previous month

Hi all. I am scripting in a POSIX shell on HPUX. I am running a script that needs to determine the number of days in a month. I found this on the forum and it works great: X=`cal $(date +%m) $(date +%Y) | grep -v '' | wc -w` The issue is that I am running the script on the 7th day of... (11 Replies)
Discussion started by: lyoncc
11 Replies

9. UNIX for Dummies Questions & Answers

using 'date' to get previous days' dates

I am familiar with using the 'date' command to get the current date but I have a situation where I need to get the previous day's date as well as the date two days prior. Theoretically I could use 'expr' to compute these values but I need it to work in instances where the previous month's dates... (2 Replies)
Discussion started by: slant-40
2 Replies

10. Shell Programming and Scripting

ls latest 4 days or specify days of files in the directory

Hi, I would like to list latest 2 days, 3 days or 4 days,etc of files in the directory... how? is it using ls? (3 Replies)
Discussion started by: happyv
3 Replies
Login or Register to Ask a Question