how to grep string from hourly basis files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to grep string from hourly basis files
# 1  
Old 08-25-2010
how to grep string from hourly basis files

dear all,

pls help on this script..

i have many files which will be created every mins in particular directory.

i want to grep a particular string from only for unique hour files.

from the below code i want to grep a string from only 9th hour files .
Ex files:
Code:
-rw-r--r--   1 root     root      580988 Aug 25 09:46 IE1_CV_25_08_2010_09_39_50_006382.cdr
-rw-r--r--   1 root     root      594808 Aug 25 09:51 IE1_CV_25_08_2010_09_44_51_006383.cdr
-rw-r--r--   1 root     root      594468 Aug 25 09:56 IE1_CV_25_08_2010_09_49_52_006384.cdr
-rw-r--r--   1 root     root      638385 Aug 25 10:01 IE1_CV_25_08_2010_09_54_53_006385.cdr
-rw-r--r--   1 root     root      668880 Aug 25 10:05 IE1_CV_25_08_2010_09_59_54_006386.cdr
-rw-r--r--   1 root     root      691399 Aug 25 10:10 IE1_CV_25_08_2010_10_04_55_006387.cdr
-rw-r--r--   1 root     root      662416 Aug 25 10:15 IE1_CV_25_08_2010_10_09_56_006388.cdr

thanks
# 2  
Old 08-25-2010
Code:
grep "string"  *_2010_09_*

# 3  
Old 08-25-2010
hi Girija,

I want to grep with respect to system timing .. not with files timing ..

could u help me?

thanks
# 4  
Old 08-25-2010
Code:
 ls -ltr | awk '{print $8 " " $9}' | grep "09" | awk '{print $2}' | xargs  grep "string"

string -> represents string to grep

---------- Post updated at 06:55 PM ---------- Previous update was at 06:53 PM ----------

Try the above command and see whatever u excepted is achieved
# 5  
Old 08-25-2010
Code:
grep "09:"

or
Code:
awk '$8 ~ /^09:/'

# 6  
Old 08-25-2010
Code:
# ls -ltr | sed -n '/09:.*/p'

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Combining files(every 15 min) as one file(hourly)

Hello, My system is generating two files every 15 minutes and file names are given automatically as below. (98,99,89,90 are the sequence numbers) File1_09242013131016_000000098 File1_09242013131516_000000099 File2_09242013124212_000000089 File2_09242013124712_000000090 I want to combine... (6 Replies)
Discussion started by: phoenex11
6 Replies

2. Shell Programming and Scripting

Calculate avg response time on hourly basis

Hi, I am trying to calculate avg response time on hourly basis from the log file which has millions of records. As of now I am trying with creating temp file which will have lines with unique id and start time and end time and after that another script will run on this temp file to... (7 Replies)
Discussion started by: random_thoughts
7 Replies

3. Shell Programming and Scripting

Grep string in files and list file names that contain the string

Hi, I have a list of zipped files. I want to grep for a string in all files and get a list of file names that contain the string. But without unzipping them before that, more like using something like gzcat. My OS is: SunOS test 5.10 Generic_142900-13 sun4u sparc SUNW,SPARC-Enterprise (8 Replies)
Discussion started by: apenkov
8 Replies

4. Shell Programming and Scripting

Crontab on hourly basis

Hi.. I need to run the script on hourly basis. How do I write the crontab on hourly basis i.e, 9:00, 10:00.....22:00.. 23:00 hours Please let me know if the below is correct one for crontab on hourly basis. 00 * * * * ksh myscript.ksh > /dev/null Regards, John (3 Replies)
Discussion started by: scriptscript
3 Replies

5. Shell Programming and Scripting

grep exact string from files and write to filename when string present in file

I am attempting to grep an exact string from a series of files within a directory and append that output to the filename when it is present in the file. I've been after this all day with no luck. Thanks for your help in advance :wall:. (4 Replies)
Discussion started by: JC_1
4 Replies

6. Shell Programming and Scripting

FTP a file on Hourly basis

Hi, I have to upload a file test_201105281100.txt to a ftp location. The files will be created on hourly basis like test_201105281100.txt, test_201105281200.txt & so on. After a file is uploaded successfully, I need to rename the file as test_201105281100.success & if it is not uploaded... (11 Replies)
Discussion started by: SunilB2011
11 Replies

7. Solaris

Monitoring the output of 'top' command on hourly basis.

I need to capture the following data on an hourly basis through cronjob scheduling:- 1. load averages 2. Total no. of processes. 3. CPU state 4. Memory 5. Top 3 process details. All the above information is available through the command 'top'. But here we need to automate the same and... (4 Replies)
Discussion started by: subharai
4 Replies

8. UNIX for Dummies Questions & Answers

Taking a Users input to for the basis of a Grep

Hi I'm currently putting together a script that will grep a set of data for a particular input, specified by the user. I'm getting myself all tangled up with my Echo's and reads. What i'm looking to do is get it so that it prompts the user to enter a value (echo) and then uses their input... (5 Replies)
Discussion started by: Great Uncle Kip
5 Replies

9. UNIX for Dummies Questions & Answers

count string occurance in a file hourly

Hi, I file that has all the status for one day (24hours). Now what I want to do is to count the occurence of a string in its output hourly like for example count occurance of successful or asynchronous clear destinon for every hour and redirect it to file. Please see sample file below. Please... (2 Replies)
Discussion started by: ayhanne
2 Replies
Login or Register to Ask a Question