Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get only certain text 1

Status
Not open for further replies.

kHz

MIS
Dec 6, 2004
1,359
US
I have a file that is tens of thousands of lines. Each line is hundreds of characters. In each line I want to grab only certain text, and nothing but that. A grep will return the entire line, but that isn't what I need.

The line is like this:
xx.xx.xx.xx - [01/Jan/2003:08:18:23 -0800] "GET /path/to/file.png?(225x225) HTTP/1.1" 200 .....blah blah blah

What I need to extract is just:
(225x225)

Thanks.
 
Code:
nawk 'match($0, "[(][0-9][0-9]*x[0-9][0-9]*[)]") {print subst($0, RSTART, RLENGTH)}' myFile.txt

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top