40
21

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.

sudoとヒアドキュメントでファイルを作成する小技

Posted at
sudo cat<<EOF > /etc/hogehoge.conf
this is a hove
EOF

とやってもエラーになりますよね。

sudo tee /etc/hogehoge.conf <<EOF
this is a hove
EOF

とやればエラーになりません。もし、標準出力に出るのが嫌ならば、

sudo tee /etc/hogehoge.conf <<EOF >/dev/null
this is a hove
EOF

などとすれば良いです。

40
21
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
40
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?