Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
20
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

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

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

などとすれば良いです。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
20
Help us understand the problem. What are the problem?