[linux-l] Wie kann ich mit sed aus einer Datei lesen und in sie schreiben?
Philipp Grau
phgrau at ZEDAT.FU-Berlin.DE
Fr Apr 20 22:35:29 CEST 2012
Hallo,
* Thomas Kaepernick <mast_1 at gmx.net> [20.04.12 21:27]:
> sed '/RegEx/ s/string1/string2/' file > file
Versuche es mal mit sed -i:
,----[ man sed ]---
|
| -i[SUFFIX], --in-place[=SUFFIX]
|
| edit files in place (makes backup if extension supplied)
|
`----
Wobei dein Syntax auch etwas komisch aussieht (also die RegEx ohne sonstige
Angaben). Ich würde sowas wie erwarten:
,----[ Beispiel ]---
| $ cat test.txt
| aaa
| nnn
| bbb
| abb
| abb
|
| $ sed 's/abb/xxx/' test.txt
| aaa
| nnn
| bbb
| xxx
| xxx
|
| $ cat test.txt
| aaa
| nnn
| bbb
| abb
| abb
|
| $ sed -i 's/abb/xxx/' test.txt
| $ cat test.txt
| aaa
| nnn
| bbb
| xxx
| xxx
`----
Gruss,
Philipp
Mehr Informationen über die Mailingliste linux-l