Grep a pattern in current date logs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grep a pattern in current date logs
# 1  
Old 04-13-2014
Grep a pattern in current date logs

Hello,
I need to write one script which should search particular pattern like ABCD in log file name hello.txt only in current date logs.

in current directory i have so many past date logs but grep should be applied on current date logs.

on daily basis current date logs are in number 30 and no time stamps appended to the log, only by ls -lrt can find out which logs belongs to which date.

say
hello1.txt
hello2.txt
hello3.txt.... so on till 30
if i do ls -lrt i can know the log is of current date or past date

so here how i can use grep to search pattern ABCD in hello*.txt for only current date.

as the above one is searching for all the logs resides in the same directory and looks like its a time and resource consuming.

Any suggetion or comment.

f
# 2  
Old 04-13-2014
Code:
find . -type f -name "hello*.text" -mtime -1 | xargs grep "ABCD"

# 3  
Old 04-14-2014
Sorry,
The above one is not working, looks -mtime not applicable.
This is an AIX flavour

---------- Post updated at 11:57 PM ---------- Previous update was at 05:03 AM ----------

Any update
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep date pattern folder and zip -->delete

Hi All, OS: Redhat Linux 7.5 Shell: Bash I have some folder like this 2018-09-16 2018-09-17 2018-09-18 2018-09-19 and so on... Everyday one script create a folder with pattern YYYY-MM-DD (it will have so many sub directories files in it) Now what I would like to achieve is a... (1 Reply)
Discussion started by: onenessboy
1 Replies

2. Shell Programming and Scripting

If I ran perl script again,old logs should move with today date and new logs should generate.

Appreciate help for the below issue. Im using below code.....I dont want to attach the logs when I ran the perl twice...I just want to take backup with today date and generate new logs...What I need to do for the below scirpt.............. 1)if logs exist it should move the logs with extention... (1 Reply)
Discussion started by: Sanjeev G
1 Replies

3. UNIX for Beginners Questions & Answers

Grep a pattern & Email from latest logs

MyLOG: 2017/11/12 17:01:54.600 : Error: LPID: 3104680848 WRONG CRITERIA FOUND. tRealBuilder::Generate Output Required: If Ke word "WRONG CRITERIA FOUND" in latest log ( logs are regularly generating - real time) mail to us once mailed wait for 2 hours for second mail. mail subject... (3 Replies)
Discussion started by: vivekn
3 Replies

4. Shell Programming and Scripting

How to extract logs between the current time and the last 15 minutes ?

I want to extract the logs between the current time stamp and 15 minutes before and sent an email to the people configured. I developed the below script but it's not working properly; can someone help me?? I have a log file containing this pattern: Constructor QuartzJob ... (3 Replies)
Discussion started by: puneetkhullar
3 Replies

5. Shell Programming and Scripting

sed and awk usage to grep a pattern 1 and with reference to this grep a pattern 2 and pattern 3

Hi , I have a file where i have modifed certain things compared to original file . The difference of the original file and modified file is as follows. # diff mir_lex.c.modified mir_lex.c.orig 3209c3209 < if(yy_current_buffer -> yy_is_our_buffer == 0) { --- >... (5 Replies)
Discussion started by: breezevinay
5 Replies

6. Shell Programming and Scripting

Script to Search Logs Several Directories Pulling out Only Current Date

Hi All.. I'm seeking assistance with editing a script to search log files in several directories. I'm close to what I'm seeking, but need additional guidance. The log files are always listed by current date; however, inside the log file includes dates that go back to 2011. What I'm... (6 Replies)
Discussion started by: lenaf7
6 Replies

7. Shell Programming and Scripting

Date One Week Ago From Given Date, Not From Current Date

Hi all, I've used various scripts in the past to work out the date last week from the current date, however I now have a need to work out the date 1 week from a given date. So for example, if I have a date of the 23rd July 2010, I would like a script that can work out that one week back was... (4 Replies)
Discussion started by: Donkey25
4 Replies

8. AIX

how to grep and compare timestamp in a file with the current date

I want to read a log file from a particular location.In the log file each line starts with timestamp.I need to compare the timestamp in the logfile with the current date.If the timpestamp in the log file is less than 4 hours then i need to read the file from that location.Below is the file... (1 Reply)
Discussion started by: achu
1 Replies

9. AIX

how to grep and compare timestamp in a file with the current date

I want to read a log file from a particular location.In the logfile , lines contains timestamp.I need to compare the timestamp in the logfile with the current date.If the timpestamp in the log file is less than 4 hours then i need to read the file from that location.Below is the file format.Please... (1 Reply)
Discussion started by: achu
1 Replies

10. Shell Programming and Scripting

Grep yesterday logs from weblogic logs

Hi, I am trying to write a script which would go search and get the info from the logs based on yesterday timestamp and write yesterday logs in new file. The log file format is as follows: """"""""""""""""""""""""""... (3 Replies)
Discussion started by: harish.parker
3 Replies
Login or Register to Ask a Question