Chris Schuld's Blog

personal musings on the composition of software

Written By: Chris Schuld Thursday, August 9th, 2007

Another task which hits my desk often is getting “data” out of text files. Such as names, email addresses, phone numbers, ID numbers, etc. Here is a quick way to parse or rip out “data” from a text file.

I suggest using ‘grep’ — grep is one of those applications which is more powerful than the casual user realizes. And let’s face it, if you use or know what grep is you probably do not consider yourself a casual user.

grep -o -P "[regex_pattern]" [filename]

The -o tells grep to only output what it matched in your pattern where your [regex_pattern] is your pattern.
The -P tells grep to use Perl Regular Expressions

Categories: Linux, Regex

Leave a Reply

About Chris

Chris Schuld

Thank you for visiting my website. I use this site for a myriad of things: maintaining software I have open sourced, connecting with my readers and friends and documenting all of this little things "I wished I would have written down." You can read more about me or contact me.


thanks for visiting... happy coding

Recent Comments