Parsing Out Specific Values In a Text File

- 09 Aug 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

Related Posts: Extracting Smarty variables from source » Installing vzdump on CentOS 5.4 (32-bit) » Dumping Addresses from phplist » Adding NRPE (Nagios) to CentOS \/ RHEL Servers » Adding the REMI Repository to CentOS / RHEL / RedHat »

comments powered by Disqus