Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Regular Expression Search and parse?



 Mark Woodward wrote: 
> So, if I have file with a lot of lines that look like this: 
> 
> Title: The Long and Winding Road [ISBN:123456] 
> Descr: A boring book about boring roads 
> Author: A dull cab driver 

How about this: 
# cat books.txt | grep '^Title\: ' | sed 's/.*\[//' | sed 's/\]//' 

redirect that to an output file using " > isbns.txt" and you have your 
ISBN numbers. If you just want the numbers, and not the "ISBN: ", then 
change the first call to sed like this: sed 's/.*\[ISBN\://' 


You could probably combine the last 2 seds, but this should do what you 
asked. You could also make it some sort of alias with $1, $2, and $3 
inputs, and do something like: 
cat file | myreplacer '^Title\: ' 's/.*\[//' 's/\]//' > outfile.txt 

Grant M. 
-- 
Grant Mongardi 
Senior Systems Engineer 
NAPC 

[hidden email] 
http://www.napc.com/
781.894.3114 phone 
781.894.3997 fax 

NAPC | technology matters 


-- 
This message has been scanned for viruses and 
dangerous content by MailScanner, and is 
believed to be clean. 

_______________________________________________ 
Discuss mailing list 
[hidden email] 
http://lists.blu.org/mailman/listinfo/discuss
 


BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org