28
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

sedで最終行に挿入

Posted at

Dockerfile内で最終行に文字を挿入したくなった。

参考

最終行に挿入

$ 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
28
22
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
28
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?