[PLUG] File content modification

Kulkarni Shantanu linux at shantanukulkarni.org
Sun Aug 1 14:16:06 IST 2010


* Shreerang Patwardhan <patwardhan.shreerang at gmail.com> [100801 14:03]:
> Hello all,
>      I have a file with contents in the following manner:
> 10001_abc_county
> 10003_abc_xyz_county
> 10005_abc_pqr_xyz_county
> 
> Each entry is on a new line and each line begins with a number and ends with
> the word county!
> 
> I wish to convert the contents of this file in the form as specified below:
> abc
> abcxyz
> abcpqrxyz

A dirty hack for this would be something like this, (untested but just
to give you a general idea),

sed -e '^\([0-9]\{5\}\)_\(.*\)_county/\2/' -e 's/-//g' filename

Assuming that digit is 5 char long and line ends with"_county".
If any help needed some sample of actual data.

Shantanu
www.shantanukulkarni.org
-- 




More information about the Plug-mail mailing list