使用sed命令在最后一行插入

在Dockerfile中,我想在最后一行插入文字。

请参考

    Sed Command in Linux – Append and Insert Lines to a File ~ Your Own Linux..!

最后插入在最后一行

$ sed -e '$ a hoge' sources.list.bak 
deb http://httpredir.debian.org/debian stretch main
deb http://httpredir.debian.org/debian stretch-updates main
deb http://security.debian.org stretch/updates main
hoge

在最后一行的前一行插入

$ sed -e '$ i hoge' sources.list.bak 
deb http://httpredir.debian.org/debian stretch main
deb http://httpredir.debian.org/debian stretch-updates main
hoge
deb http://security.debian.org stretch/updates main

随意插入到任意的行中

$ sed -e '2i hoge' sources.list.bak 
deb http://httpredir.debian.org/debian stretch main
hoge
deb http://httpredir.debian.org/debian stretch-updates main
deb http://security.debian.org stretch/updates main
广告
将在 10 秒后关闭
bannerAds