LoginSignup
39
21

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

などとすれば良いです。

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