cat try.txt | cut -d '_' -f2- | rev | cut -d '_' -f2- | rev Manas
On Sat, Aug 7, 2010 at 2:38 AM, zoyd <emailz...@yahoo.com> wrote: > On Tue, Aug 3, 2010 at 9:10 AM, Gaurav Pant <gauravggs at gmail.com> > wrote: > >> 2010/8/3 शंतनू (Shantanoo) <shantanoo at gmail.com>: > >>> On Sat, Jul 31, 2010 at 12:32, Shreerang Patwardhan > >>> <patwardhan.shreerang at gmail.com> 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 with > >>>> the word county! > > > >Can be done with awk too.. > > > > cat file | awk -F'_' '{ for(i=2;i<NF;i++) printf("%s", $i); printf("\n") > >}' > > > > can be done without sed/awk/perl/python/whatnot > > for i in `cat file` ; do nohead=`echo $i | cut -d "_" -f2-` ; tail=`echo > $nohead | grep -o "_" | wc -l`; body=`echo $nohead | cut -d "_" -f-$tail | > tr -d "_"`; echo $body ;done > > -- > zoyd > > > > > > _______________________________________ > Pune GNU/Linux Users Group Mailing List _______________________________________ Pune GNU/Linux Users Group Mailing List