need to grep contents of a file within specific time span. regex i am using is not working


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need to grep contents of a file within specific time span. regex i am using is not working
# 8  
Old 05-30-2012
Try with

Code:
/usr/xpg4/bin/egrep

This User Gave Thanks to elixir_sinari For This Post:
# 9  
Old 05-30-2012
try this Smilie
Code:
/usr/xpg4/bin/grep -E 'May 29 15:([01][0-9]|[2][0-3]):[0-9]'

This User Gave Thanks to ygemici For This Post:
# 10  
Old 05-30-2012
Try:
Code:
/usr/xpg4/bin/grep -E '^May 29 15:([01]|2[0-3])' /var/adm/messages

This User Gave Thanks to Scrutinizer For This Post:
# 11  
Old 05-30-2012
/usr/xpg4/bin/grep -E 'May 29 15:[0-9]{2}:[0-9]{2}' /var/adm/messages

works Smilie

but why not egrep 'May 29 15:[0-9]{2}:[0-9]{2}' /var/adm/messages ???

Please if some one has some details one the regex compatibility table with unix tools ( e.g. grep , grep , sed , awk , nawk and so ) that would be much helpful

Last edited by chidori; 05-30-2012 at 10:01 AM..
# 12  
Old 05-30-2012
There is no data between 15:00:00 and 15:23:59 on May 29 in that file..

-----
use /usr/xpg4/bin/grep -E or /usr/xpg4/bin/egrep on Solaris

Last edited by Scrutinizer; 05-30-2012 at 10:10 AM..
# 13  
Old 05-30-2012
Quote:
Originally Posted by Scrutinizer
There is no data between 15:00:00 and 15:23:59 on May 29 in that file..

you are right!!

sorry scurtinizer and ygemici , just now tried your codes on another file and voila!! it worked Smilie
# 14  
Old 05-30-2012
Quote:
Originally Posted by chidori
/usr/xpg4/bin/grep -E 'May 29 15:[0-9]{2}:[0-9]{2}' /var/adm/messages

works Smilie

but why not egrep 'May 29 15:[0-9]{2}:[0-9]{2}' /var/adm/messages ???

Please if some one has some details one the regex compatibility table with unix tools ( e.g. grep , grep , sed , awk , nawk and so ) that would be much helpful
SUNWcsu is a core solaris package and grep an egrep and the others (/usr/bin/..) packages belong to that.

SUNWxcu4 utilities are like an enchanced the core utilities with XCU4(i m not sure but is is extendend core utilities) specifications..
These commands are an XPG4(X/Open Portability Guide) superset of Posix standarts from previous superset (XPG3)..
These packages are improved by the X/Open Company, Ltd and adapted to Sun (Sparc and x86 for Sun) platforms by the Oracle (Sun Microsystems ).
so the other name is X/Open Commands & Utilities..
and XCU4 utulities are placed in the "/usr/xpg4/bin" folder for prevent the conflicts with existing Solaris behavior and these are suitable the POSIX.2 standarts.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep a log file starting from a specific time to the end of file

I have a log file which have a date and time at the start of every line. I need to search the log file starting from a specific time to the end of file. For example: Starting point: July 29 2018 21:00:00 End point : end of file My concern is what if the pattern of `July 29 2018 21:00:00`... (3 Replies)
Discussion started by: erin00
3 Replies

2. UNIX for Beginners Questions & Answers

Total size utilizes by the files older than a time span

Through find command I identified the files older that 1 year. I need the overall size utilizes by these 1 year older files. Please share me the command to identify it .Thanks Please post in an adequate technical forum! (3 Replies)
Discussion started by: Sang
3 Replies

3. Shell Programming and Scripting

awk to place specific contents filename within text file

I am trying to use awk to place the contens of a filename in $1 and $2 followed by the data in the text file. Basically, put the filename within the text file. There are over 1000 files in the directory and as of now each file is saved with a unique name but it is not within the file. Thank you... (10 Replies)
Discussion started by: cmccabe
10 Replies

4. UNIX for Dummies Questions & Answers

Looping/Reading file contents not working

Hi, I am doing something basic, but I am missing something. Im trying to read the contents of a file and taking those values and connecting to a database. However, it only connect to one (or reads in) value and then exists. Here is what it looks like: listname.txt db1 db2 db3 Script:... (15 Replies)
Discussion started by: DBnixUser
15 Replies

5. Shell Programming and Scripting

select the lines in between some time span

Hi Everyone ! i want to take all the lines from a file that falls in between some date... and every line in a file has a time stamp.. ---some text---- 01/Jan/2010 ---- some other text ---- ---some text---- 10/Jan/2010 ---- some other text ---- ---some text---- 20/Dec/2010 ---- some... (3 Replies)
Discussion started by: me_newbie
3 Replies

6. Shell Programming and Scripting

How to replace specific contents in a file?

From the existing file, I need to replace specific contents possibly with var every time when the user changes the var. e.g the contents in the file file.txt is 'My name is $n and I am $y years old' and every time user changed the var outside the file, the contents of the file should be created... (4 Replies)
Discussion started by: Emilywu
4 Replies

7. UNIX for Dummies Questions & Answers

Extracting a Time Span from Syslog Messages File

Hi all, I need your help to explain how I can extract a time span from the syslog messages file on a Solaris 10 system. Here is an example extract of the syslog messages: Dec 4 11:51:38 hajap141-0107.nls.jlrint.com 267938: Dec 4 11:51:36: %DOT11-6-DISASSOC: Interface Dot11Radio0,... (4 Replies)
Discussion started by: wthomas
4 Replies

8. Shell Programming and Scripting

Bash copy file contents into an existing file at a specific location

Hi all I need to copy the entire contents of one file into an existing file at a specific location. I know the exact line number where I need to put it. It appears I would use either sed or awk to do this, but I have been unsuccessful so far: File A line 1 line 2 line 3 line 4 ... (6 Replies)
Discussion started by: gshepherd7
6 Replies

9. Shell Programming and Scripting

awk - print file contents except regex

Hello, I have a file which has user information. Each user has 2 variables with the same name like Email: testuser1 Email: testuser1@test.com Email: testuser2 Email: testuser2@test.com My intention is to delete the ones without the '@' symbol. When I run this statement awk '/^Email:/&&!/@/'... (6 Replies)
Discussion started by: rmsagar
6 Replies

10. Shell Programming and Scripting

Reading specific contents from a file and appending it to another file

Hi, I need to write a shell script (ksh) to read contents starting at a specific location from one file and append the contents at specific location in another file. Please find below the contents of the source file that I need to read the contents from, File 1 -----# more... (5 Replies)
Discussion started by: dnicky
5 Replies
Login or Register to Ask a Question