The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Special Forums > UNIX Desktop for Dummies Questions & Answers
.
google unix.com




Thread: Grep
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 05-25-2009
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,555
if you have Python

Code:
#!/usr/bin/env python
for line in open("file"):
    if "N1*PR*" in line:
        ind=line.index("N1*PR*")
        print line[ind+6:].split("*")[0]

output

Code:
# ./test.py
CALIFORNIA