Find files of particular day


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find files of particular day
# 8  
Old 08-04-2010
Code:
$ ls -l | awk '/Aug  2/ { print $NF }' | xargs grep -c 'sachin'

Or

Code:
$ for f in $(ls -l | awk '/Aug  2/ { print $NF }'); do grep -c 'sachin' $f; done

# 9  
Old 08-04-2010
OR
Code:
 grep "sachin" `ls -ltr | grep " Aug 2 " | awk '{print $9}'`

# 10  
Old 08-04-2010
Quote:
Originally Posted by agn
[code]
$ ls -l | awk '/Aug 2/ { print $NF }' | xargs grep -c 'sachin'

This is wat i was looking for. Can you tell me what is xargs and what does it do . Also, it gives me filenames and the count of string 'sachin' in that file. Is there any way that I can just get the total count without all the files list..

Or

Code:
$ for f in $(ls -l | awk '/Aug  2/ { print $NF }'); do grep -c 'sachin' $f; done

# 11  
Old 08-04-2010
Code:
ls -l | awk '/Aug 2/ { print $NF }' | xargs grep -c 'sachin' | awk -F ":" '{ total += $2 } END {print total}';

# 12  
Old 08-04-2010
Hi Pravin..

I tried what u said but it gives me the below error:

awk: syntax error near line 1
awk: bailing out near line 1
$ xargs: Child killed with signal 13
# 13  
Old 08-04-2010
It's running fine for me. You can try another one.

Code:
total=0;for f in $(ls -l | awk '/Jun 22/ { print $NF }'); do cnt=`grep -c 'pravin' $f` total=`expr $cnt + $total`;done ; echo $total

# 14  
Old 08-04-2010
If you are on Solaris, try "nawk" not "awk".
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Error when connecting to remote server to find files with timestamp today's day

I am connecting to remote server and try to check if files with timestamp as Today's day are on the directory. Below is my code TARFILE=${NAME}.tar TARGZFILE=${NAME}.tar.gz ssh ${DESTSERVNAME} 'cd /export/home/iciprod/download/let/monthly; Today=`date +%Y%m%d`; if ;then echo "We... (1 Reply)
Discussion started by: digioleg54
1 Replies

2. Shell Programming and Scripting

Find list of files modified for a given day ?

find list of files modified for a given day ? if i have 10 files in my directory, i have modified only 5 ... how to display only modified files ? (1 Reply)
Discussion started by: only4satish
1 Replies

3. HP-UX

Find Day of Week

In HP-UX the date command does not have the "-d" switch like some other *nixes do. I'm working a simple script to tell me, given the day, month and year what day of the week that falls on. Assuming valid day, month and year input (I'd perform quality checks on the input separately, but not... (5 Replies)
Discussion started by: rwuerth
5 Replies

4. UNIX for Dummies Questions & Answers

Move the files between Current day & a previous day

Hi All, I have a requirement where I need to first capture the current day & move all the files from a particular directory based on a previous day. i.e move all the files from one directory to another based on current day & a previous day. Here is what I am trying, but it gives me errors.... (2 Replies)
Discussion started by: dsfreddie
2 Replies

5. Shell Programming and Scripting

find files for next day of the date entered

i have few files generated everyday with a date stamp. Sometimes it happens that if the files are generated late i.e after 00:00 hrs the date stamp will be of the next day. example: 110123_file1 110123_file2 110123_file3 110124_file4 in the above example file4 is also for the previous... (2 Replies)
Discussion started by: gpk_newbie
2 Replies

6. Shell Programming and Scripting

Find the number of files older than 1 day from a dir

Hello All, I need to write a script/command which can find out the number of .csv files residing in a directory older than 1 day. The output should come with datewise (means for each date how many files are there). I've this command, but this command gives the total number of files. It's... (10 Replies)
Discussion started by: NARESH1302
10 Replies

7. Shell Programming and Scripting

to find all files created a day back

Hi Guys, My unix is SunOS. I like to find all the files which are created 1 day back. i tried the following command find . -type f -name '*.aud' -mtime +1 This gives me all the files created 48 hours back (2 days) but not one.. Can you let me know where i am going wrong. Thanks,... (8 Replies)
Discussion started by: mac4rfree
8 Replies

8. Shell Programming and Scripting

Script to find previous month last day minus one day timestamp

Hi All, I need to find the previous month last day minus one day, using shell script. Can you guys help me to do this. My Requirment is as below: Input for me will be 2000909(YYYYMM) I need the previous months last day minus 1 day timestamp. That is i need 2000908 months last day minus ... (3 Replies)
Discussion started by: girish.raos
3 Replies

9. Shell Programming and Scripting

find files modified more than a day

Hi All, I am using the below command to check the files modified within last 24hours find /home/karthik -mtime -1 -type f -exec ls -l {} \; What parameter do i need to add in the above command to check the files modified in last 2 or 3 days Kindly let me know if any other alternative... (2 Replies)
Discussion started by: karthikn7974
2 Replies

10. Shell Programming and Scripting

Write a shell script to find whether the first day of the month is a working day

Hi , I am relatively new to unix... Can u pls help me out to find out if the first day of the month is a working day ie from (Monday to Friday)...using Date and If clause in Korn shell.. This is very urgent. Thanks for ur help... (7 Replies)
Discussion started by: phani
7 Replies
Login or Register to Ask a Question