RE: lug-bg: grep, sed, cut - output manipulating
- Subject: RE: lug-bg: grep, sed, cut - output manipulating
- From: bkrosnov@xxxxxxxx (Boyan Krosnov)
- Date: Sun, 9 Sep 2001 20:54:13 +0300
lesno i prosto reshenie:
izpolzwaj perl za da imash poweche "lesen" kontrol.
perl -ne ' chomp; if (m/pattern/) { print $&,"\n"; } '
BR,
Boyan
> -----Original Message-----
> From: George Danchev [mailto:danchev@xxxxxxxxx]
> Sent: Sunday, September 09, 2001 2:42 PM
> To: lug-bg@xxxxxxxxxxxxxxxxxx
> Subject: Re: lug-bg: grep, sed, cut - output manipulating
>
>
> On Sunday 09 September 2001 13:02, you wrote:
> > On Sun, 9 Sep 2001, George Danchev wrote:
> > > imam sledniq vupros:
> > > grep-vam po daden patern , oba4e iskam da se output-vat
> samo stringovete
> > > otgovarqsti na kriteriq, a ne celite redove. Primer sys
> slu4aen input:
> > > cat random_text.txt | grep appl
> > > ste output-ne celi redove sydyrzhasti "app", no kak da gi
> "iz4istq" taka,
> > > 4e da se output-vat samo stringove otgovqrqsti na
> patern-a - primerno
> > > apple , application i t.n.?
>
> da no ako tyrsenite stringove sa sami na red togava da,
> ama v moq slu4aj ne sa
> input.txt:
> banana sdfsdf dfssd
> apple efwedf swefswfdv
> lemon sdfsdgvverf gre rg
> peach sefsvgfs fdgfg frg
> ta za tova samo:
> cat input.txt | egrep "(lemon|apple)"
> ( ili cat input.txt |grep -E "(lemon|apple)")
> ne mi vurshat rabota , stoto vzemat cql red,
> ama se cut-va po position, koeto po-kusno razbrah.
> (Greshno bqh razbral cut --characters=LIST )
> > > izvesten po podredba (predvidim) input:
> > > primerno:
> > > #!/bin/bash
> > > IP=`ifconfig |grep 212.*`
> > >
> > > mozhe li da se output-ne za dadeniq line, samo char-ovete
> primerno ot
> > > 10-25 vklu4itelno i nisto drugo ?
>
> imah predvid 4e ponqkoga se znae podredbata na outputted line,
> i iskam da vzema symvolite ot poziciq ot X do Y. Shvanah kak stafa:)
> >
> > Towa ne go razbrah.
> >
> > > "interval" i "TAB" susto li se broqt za char ?
> >
> > Obiknoweno da. Za da gi izbegnesh, movesh da naprawish taka:
> >
> > input.txt:
> > asd asdasda asdasd asdasdasd
> > cat input.txt | awk '{print $1}'
> >
> > za da wzemesh pyrwata kolonka.
>
> i tova go misleh, ama ne vinagi sa po kolonki,
> pyk i az ne sym mnogo na ti s awk :)
> >
> > > "cut" i "sed" bi trqbvalo da pomognat v slu4aq ama nesto
> nezacepvam kak
> > > da gi vpregna da svurshat rabota ili mozhe bi stava i po
> drug na4in ?
> >
> > "cut" movesh da izpolzwash pri ednosimwolni razdeliteli.
> "sed" glawno za
> > zamestwane na tekts ot input-a s regexp. Wsyshtnost
> poslednoto movesh da go
> > realizirash kato zamestish interwalite i tabs w teksta s
> interwali ili drug
> > delimiter i posle go prekarash prez cut.
> >
> > Ako imash obache nqkakyw po-sloven input, po-dobre e da go
> prekarash prez
> > nqkoj Perl script, zashtoto ima dobri wyzmovnosti za
> obrabotka na tekst s
> > regexps.
> Molq,molq, blagodarq!
> Dobre de, priznavam prav si :)
>
> Thanks na vsi4ki za help-a !
> ==============================================================
> =============
> A mail-list of Linux Users Group - Bulgaria (bulgarian linuxers)
> http://www.linux-bulgaria.org/ Hosted by Internet Group Ltd.
> - Stara Zagora
>
===========================================================================
A mail-list of Linux Users Group - Bulgaria (bulgarian linuxers)
http://www.linux-bulgaria.org/ Hosted by Internet Group Ltd. - Stara Zagora
|