[PLUG] File content modification
nrmarathe at gmail.com
Sun Aug 1 22:38:44 PDT 2010
On Sun, Aug 1, 2010 at 2:40 PM, Mayuresh <mayuresh at acm.org> wrote:
> On Sat, Jul 31, 2010 at 12:32:47PM +0530, Shreerang Patwardhan wrote:
> > 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
> > the word county!
> > I wish to convert the contents of this file in the form as specified
> > abc
> > abcxyz
> > abcpqrxyz
> cat yourfile | cut -d_ -f2- | sed -e 's/_county//' -e 's/_//g'
the cat is unnecessary. Otherwise this looks the cleanest solution.
cut -d_ -f2- temp | sed -e 's/_county//' -e 's/_//g'
> Pune GNU/Linux Users Group Mailing List
More information about the plug-mail