38
25

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.

ユーザー権限で書けないファイルに対してリダイレクトで書き込みたい

Last updated at Posted at 2013-04-10
$ sudo echo 'hoge' >> /var/foo/var.txt
zsh: permission denied: /var/foo/var.txt

こういうことはできないので、いちいちrootになって作業したりする人を見かけるが、そんな必要はない。こうしよう

$ sudo sh -c "echo 'hoge' >> /var/foo/var.txt"
38
25
3

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
38
25

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?