Home » Brain teasers » How to sudo echo/cat things

How to sudo echo/cat things

Wanted to ‘cat’ a content of one file to be appended to another which had no permissions for my user, however, I had ‘sudo’ permissions. Basically failed miserably at it, then I figured it might be something to do with the ‘tee’ I knew about from vim.

Tried a

$ man tee

Which in the end lead to this:

$ cat ~/somefile | sudo tee -a /path/to/newfile

And boom! worked a charm, though dumped the content of the file to stout as well. Making it:

$ cat ~/somefile | sudo tee -a /path/to/newfile >/dev/null

solves that.

It’s one of those little brain teasers trying to figure out 😀

Posted in Brain teasers

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.