command sudo tee options filename The example below shows an unsuccessful attempt to write to the root-owned sudoex.txt. When I do the former I get this output (I've only taken the last three lines): Saving to: ‘STDOUT’Īnd when I do the latter I get the same output just without the "Cannot write to ‘-’ (Success). To enable tee to write to a root-owned file or file belonging to another user, place the sudo command right before tee. Or this: wget -O - | sudo cat /usr/local/bin/youtube-dl One more question when on the subject of using tee like this:Ĭan one not theoretically also replace tee with cat? Like this: wget -O - | sudo cat >/usr/local/bin/youtube-dl Isn't the former string of code superfluous and overly complicated when the latter two completely suffice? If I've understood correctly the former simply downloads the files and outputs the files being downloaded to standard output which is then piped through tee into the designated file as well as standard output with any additional standard output being redirected to /dev/null. The syntax is as follows echo 'text' sudo tee -a /path/to/file echo '192.168.1.254 router' sudo tee -a /etc/hosts Sample outputs: Password: 192.168.1. Is there something particular about using wget with tee that I'm missing here? Method 1: Use tee command to append to a file with sudo The tee command read from standard input (such as keyboard) and write to standard output (such as screen) and files. Or even for that matter: sudo wget -O /usr/local/bin/youtube-dl What is the difference when comparing with the following?: sudo wget -P /usr/local/bin/ The code being: wget -O - | sudo tee /usr/local/bin/youtube-dl >/dev/null So I came across this code for downloading youtube-dl using wget which pipes into tee here: How can I update youtube-dl?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |