grep a range of text


 
Thread Tools Search this Thread
Special Forums UNIX Desktop Questions & Answers grep a range of text
# 1  
Old 12-06-2011
grep a range of text

hey,
i need to grep / awk a list of "DEV ID" range for example for greping
0936 - 09C1 from this file:

Code:
0x5000097310036d05    558         1         20531  LOCAL       GLOBAL               42048000  YES  0x8e36c8bd07ce9e13  DEV ID: 0933        
0x5000097310036d05    559         1         20531  LOCAL       GLOBAL               42048000  YES  0xe986346f52b84c54  DEV ID: 0934        
0x5000097310036d05    560         1         20531  LOCAL       GLOBAL               42048000  YES  0x5c837fe19b263a7e  DEV ID: 0935        
0x5000097310036d05    561         1         20531  LOCAL       GLOBAL               42048000  YES  0xd48708fe23f68504  DEV ID: 0936        
0x5000097310036d05    562         1        524287  LOCAL       GLOBAL             1073740800  YES  0x386d773d3e48ba9b  DEV ID: 09B5        
0x5000097310036d05    563         1        524287  LOCAL       GLOBAL             1073740800  YES  0x77f801d182ce7f32  DEV ID: 09B9        
0x5000097310036d05    564         1        524287  LOCAL       GLOBAL             1073740800  YES  0x2b33a433b7e7b0b9  DEV ID: 09BD        
0x5000097310036d05    565         1        524287  LOCAL       GLOBAL             1073740800  YES  0x006b02ce5f90b05c  DEV ID: 09C1        
0x5000097310036d05    566         1        524287  LOCAL       GLOBAL             1073740800  YES  0xa79af230a0b4320b  DEV ID: 09C5        
0x5000097310036d05    567         1        524287  LOCAL       GLOBAL             1073740800  YES  0xee5a23ddfe4df8c6  DEV ID: 09C9        
0x5000097310036d05    568         1        524287  LOCAL       GLOBAL             1073740800  YES  0x01d3bfa79712cca2  DEV ID: 09CD        
0x5000097310036d05    569         1          5128  LOCAL       GLOBAL               10502400  YES  0x8ebaf554208bca9c  DEV ID: 09AC

result will be:

Code:
0x5000097310036d05    561         1         20531  LOCAL       GLOBAL               42048000  YES  0xd48708fe23f68504  DEV ID: 0936        
0x5000097310036d05    562         1        524287  LOCAL       GLOBAL             1073740800  YES  0x386d773d3e48ba9b  DEV ID: 09B5        
0x5000097310036d05    563         1        524287  LOCAL       GLOBAL             1073740800  YES  0x77f801d182ce7f32  DEV ID: 09B9        
0x5000097310036d05    564         1        524287  LOCAL       GLOBAL             1073740800  YES  0x2b33a433b7e7b0b9  DEV ID: 09BD        
0x5000097310036d05    565         1        524287  LOCAL       GLOBAL             1073740800  YES  0x006b02ce5f90b05c  DEV ID: 09C1

any help will be appreciated
# 2  
Old 12-06-2011
0936 - 09C1 is
Code:
egrep '09(3[6-9A-F]|[4-9AB][0-9A-F]|C[01])$'

(assuming hexidecimal data)
This User Gave Thanks to m.d.ludwig For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Grep for a range of numbers?

I am trying to extract specific information from a large *.sam file (it's originally 28Gb). I want to extract all lines that are on chr3 somewhere in the range of 112,937,439-113,437,438. Here is a sample line from my file so you can get a feel for what each line looks like: seq.4 0 ... (8 Replies)
Discussion started by: genGirl23
8 Replies

2. UNIX for Dummies Questions & Answers

grep only from a range of columns

Hello all, I have a .csv file with over 100 columns. I would like to grep for a pattern only searching within a range of those fields, and print the entire line. For example: grep a pattern from columns $47-$87, but print fields $0 - $100 Thanks! (9 Replies)
Discussion started by: torchij
9 Replies

3. Shell Programming and Scripting

Grep ip range

I want to find all files under /var directory that refer to any ip from 10.1.1.1 to 10.1.1.255 using grep. How can this be done. Please help (5 Replies)
Discussion started by: proactiveaditya
5 Replies

4. Shell Programming and Scripting

grep for a range of numbers

Dear Friends, I want to know how to grep for the lines that has a number between given range(start and end). I have tried the following sed command. sed -n -e '/20030101011442/,/20030101035519/p' However this requires both start and end to be part of the content being grepped. However... (4 Replies)
Discussion started by: tamil.pamaran
4 Replies

5. Shell Programming and Scripting

grep - date & time range

Hi, I need to search email files by date & time range in email files. The timezone is not important. Can someone plz advise how i can do this ? For e.g A user can specify only A single date A date range date & time range Below is part of the email file. (4 Replies)
Discussion started by: coolatt
4 Replies

6. Shell Programming and Scripting

grep for a special range

hi, i search a command to get follow solution: file: 21082009mueller01testtest 22082009mueller02testtest 23082009mueller03testtest 24082009mueller02testtest 25082009mueller03testtest Solution: I search all lines with "mueller02" at the range 8 to 17 It is possible with greb... (5 Replies)
Discussion started by: Timmää
5 Replies

7. Shell Programming and Scripting

Grep a string in a range and delete the line

Hi, i need to delete a lines after searching a particular string but this searching should only happen after the 4th line.. basically imagine a file like this From: abcd.yahoo.com To: cdeb.yahoo.com Subject: hi all sdfsd sadasd asdasd dfsdf From: abcd.yahoo.com To:... (3 Replies)
Discussion started by: depakjan
3 Replies

8. UNIX for Dummies Questions & Answers

Using grep on a range of numbers

Hi im new to unix and need to find a way to grep the top 5 numbers in a file and put them into another file. For example my file looks like this abcdef 50000 abcdef 45000 abcdef 40000 abcdef 35000 abcdef 30000 abcdef 25000 abcdef 20000 abcdef 15000 abcdef 10000 and so on... How can... (1 Reply)
Discussion started by: ProgChick2oo9
1 Replies

9. Shell Programming and Scripting

How to keep(or grep) range of line ?

I have simple text log file look like that ----------------------------------------- Mon May 8 07:02:41 2006 Some text to show log Mon May 8 07:05:30 2006 Some text to show log Some text to show log Mon May 8 07:11:07 2006 Some text to show log Mon May 8 07:45:56 2006 Some text to... (1 Reply)
Discussion started by: aungomarin
1 Replies

10. Shell Programming and Scripting

grep numbers range

I want to grep a range of numbers in a log file. My log file looks like this: 20050807070609Z;blah blah That is a combination of yr,month,date,hours,minutes,seconds. I want to search in the log file events that happened between a particular time. like between 20050807070000 to 20050822070000... (1 Reply)
Discussion started by: azmathshaikh
1 Replies
Login or Register to Ask a Question