我的Python代碼如下所示:只用在一個特定的塊大括號前添加新線SED
def one():
#lines of code
context = {
#lines of code
}
def two():
#lines of code
context = {
#lines of code
}
context.up({ #lines
})
我想在結束曲前加入兩個作用範圍內部分「一些新的生產線」大括號如下:
def one():
#lines of code
context = {
#lines of code
}
def two():
#lines of code
context = {
#lines of code
Some new line
}
context.up({ #lines
})
如何使用sed來做到這一點?
我嘗試下面的命令:
sed -i '/^def two.*context={/,/^[[:space:]]}/{s/^\([[:space:]]*\)}/\1some new line\n&/;}' file
,但它似乎並沒有做任何改變。
你想Python或sed的? –
這個問題似乎並不是關於Python的。 – khelwood
@cᴏʟᴅsᴘᴇᴇᴅ我想要使用sed進行此更改。 –