Re: lug-bg: Little help about sed editor
- Subject: Re: lug-bg: Little help about sed editor
- From: boukov@xxxxxxxxxxx (Petko Boukov)
- Date: Mon, 05 Jun 2000 06:58:33 -0700
Vyprosyt ne e za perl, no shte si pozvolja da go probutam tuk, ponezhe sed e edno ot mnogoto neshta, koito perl e 'pogylnal'. Vzeh tova ot perlfaq3, kojto mozhesh da vidish s 'man'. Izpylnjava se napravo ot komandnija red (na edin red).
perl -0777 -pe 's{www.company.com/directory}{site.company.com}gs' some_file > another_file
Sintaksisyt e pochti syshtijat, no perl pozvoljava da promenjash simvolite, zagrazhdashti regexps i po tozi nachin ne se nalaga da escape-vash slash-ovete i ne se chuvstvash vse edno igraesh hop-stop (klechka naljavo, klechka nadjasno).
Mojat syvet e da zarezhesh taja rabota sys syshtija file. Napravi si ako iskash shell script, kojto proverjava dali komandata se e izpylnila pravilno i ako da - iztriva originalnija file i preimenuva novija. Bezdrugo tova e edinstvenijat nachin. Dali shte stane nevidimo ot teb prez vremenen file ili ti sam shte si go organizirash, rezultatyt e syshtijat.
Petko
--
On Mon, 5 Jun 2000 15:01:27 Yuliy Minchev wrote:
>On Mon, 5 Jun 2000, Nikolay Kabaivanov wrote:
>
>> Zdrawejte
>> Imam problem s towa da nakaram redaktora sed da mi podmeni string ot
>> wida "www.company.com/directory" sus stringa "site.company.com"
>> problemi suzdawa naklonenata cherta "/" probwah i niakolko warianata s
>> kawicki no nesto ne stana :-(
>> Niakoj ima li ideia kak da se kaze na sed che towa e edin cial string ?
>> Po princip mezdu chertite triabwa da e "regexp".
>> eto kak probwam az :
>> -----------------------
>> /bin/sed s/www.company.com/support/support.company.com/ some_file
>> >another_file
>> -----------------------
>prosto e - da si chuval za backslash?
>
>sed -e's/www\/support/blahblah/g' < infile > outfile
>mv outfile infile
>
>> Ima il niakakuw nachin da se izbegne prenasochwaneto kum drug fajl, t.e.
>> promenite da stawat naprawo w osnownia fajla.
>> Blagodaria predwaritelno.
>moje, ako izpolzvash vi primerno
>vi infile
>
>i sled tova
>:%s/www\/support/blahblah/g
>:wq
>
>ili si napishe script da kajem na perl ili awk+shell
--== Sent via Deja.com http://www.deja.com/ ==--
Before you buy.
==================================================================
A mail-list of Linux Users Group - Bulgaria (bulgarian linuxers)
Otpiswaneto RABOTI !!! : Majordomo@xxxxxxxxxxxxxxxxxx UNSUBSCRIBE LUG-BG
http://www.linux-bulgaria.org/ Hosted by Internet Group Ltd. - Stara Zagora
|