Wie füge ich eine Zeile in einer Dateizeile in sed für Windows ein?

405
barlop

wenn ich eine Datei habe

half a pound of tuppenny rice half a pound that's the way the money goes pop goes the weasel 

Und ich möchte in Zeile 4 eine Zeile "Melasse" einfügen. So sollte es sein

half a pound of tuppenny rice half a pound of treacle that's the way the money goes pop goes the weasel 

wie kann ich das in sed für windows tun? Ich verwende gnuwin32s sed.

0

1 Antwort auf die Frage

1
barlop
C:\Users\username>type afile.txt half a pound of tuppenny rice half a pound that's the way the money goes pop goes the weasel C:\Users\username>  C:\>sed "4i\of treacle" afile.txt half a pound of tuppenny rice half a pound of treacle that's the way the money goes pop goes the weasel C:\> 

Sie können verwenden sed "3a\of treacle" afile.txt

Ich füge vor dieser Zeile ein. 4i wäre vor Zeile 4. a fügt nach dieser Zeile ein. 3a wäre nach Zeile 3. Also ist 3a dasselbe wie 4i.