sed - stream editor

Razmjena savjeta i trikova o podešavanju sustava i programa.

Moderator/ica: Moderatori/ce

Odgovori
Avatar
stefan
Moderator
Postovi: 4366
Pridružen/a: 28 sij 2009, 18:46
Spol: M
OS: openSUSE Leap KDE

sed - stream editor

Post Postao/la stefan »

cool stvar!
http://how-to.linuxcareer.com/learning- ... ux-News%29

Primjeri:

Replace every occurrence of Nick with John in report.txt

Kod: Označi sve

sed 's/Nick/John/g' report.txt
Delete all spaces in front and at the end of every line of file.txt

Kod: Označi sve

sed 's/^[ ^t]*//;s/[ ^]*$//' file.txt
Delete all blank lines from a file

Kod: Označi sve

sed '/./!d' file.txt
Like some other animals, the gecko can perform a neat trick when threatened by a predator: it can amputate its own tail. The dropped tail serves to distract the predator, and by losing it, the lizard can run faster.
Avatar
shrike
Moderator
Postovi: 10322
Pridružen/a: 07 pro 2007, 18:07
Spol: Y
OS: utuntu 19.10
Kontakt:

Re: sed - stream editor

Post Postao/la shrike »

Veoma zgodno:) Budem to uposlio
Es gibt keinen Gott, kein Universum, keine menschliche Rasse, kein irdisches Leben, keinen Himmel, keine Hölle. Es ist alles ein Traum - ein grotesker und dummer Traum. Nichts existiert außer dir. Und du bist nur ein Gedanke - ein vagabundierender Gedanke, ein nutzloser Gedanke, ein heimatloser Gedanke, der verloren in der leeren Ewigkeit wandelt!
Avatar
glaskoncILLa
Postovi: 5678
Pridružen/a: 28 vel 2009, 16:36

Re: sed - stream editor

Post Postao/la glaskoncILLa »

bemu misa, pa sed je stvarno stara novost.. :)

anyway, jako zgodno, pogotovo u skriptama za pretvoriti nesto u nesto drugo.
...."Have you mooed today?"...
..It’s that time of the decade: I’m reinstalling Debian..
Avatar
glaskoncILLa
Postovi: 5678
Pridružen/a: 28 vel 2009, 16:36

Re: sed - stream editor

Post Postao/la glaskoncILLa »

da, mislim da u clanku nisu naveli nijedan primjer sa sed -i koji cijelu stvar cini jos mocnijom i jednostavnijom u nekim slucajevima.
...."Have you mooed today?"...
..It’s that time of the decade: I’m reinstalling Debian..
Lutherus

Re: sed - stream editor

Post Postao/la Lutherus »

Kod: Označi sve

sed '/^#\S/ s|#||' -i mirrorlist.backup
jedan od korisnih primjera
Avatar
jjj
Postovi: 1451
Pridružen/a: 04 lip 2009, 00:46
OS: Nepu Yvahk
Lokacija: Classyfied

Re: sed - stream editor

Post Postao/la jjj »

glaskoncILLa je napisao/la:bemu misa, pa sed je stvarno stara novost.. :)
Čekaj samo, bit će još i awk i ed i tr i cut :)
Odgovori