Как вставить строку в строку файла в sed для windows?

344
barlop

если у меня есть файл

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

И я хочу вставить строку "патока" в строке 4. так должно быть

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

Как я могу сделать это в Sed для Windows. Я использую Sed Gnuwin32.

0

1 ответ на вопрос

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:\> 

you can use sed "3a\of treacle" afile.txt

i inserts before that line. 4i would be before line 4. a inserts after that line. 3a would be after line 3. so, 3a is the same as 4i.

Похожие вопросы