So I came across this code for downloading youtube-dl using wget which pipes into tee here: How can I update youtube-dl?
The code being:
wget -O - https://yt-dl.org/downloads/latest/youtube-dl | sudo tee /usr/local/bin/youtube-dl >/dev/null
What is the difference when comparing with the following?:
sudo wget -P /usr/local/bin/ https://yt-dl.org/downloads/latest/youtube-dl
or even for that matter:
sudo wget -O /usr/local/bin/youtube-dl https://yt-dl.org/downloads/latest/youtube-dl
Is there something particular about using wget with tee that I'm missing here?
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. Isn't the former string of code superfluous and overly complicated when the latter two completely suffice?
One more question when on the subject of using tee like this:
Can one not theoretically also replace tee with cat? Like this:
wget -O - https://yt-dl.org/downloads/latest/youtube-dl | sudo cat >/usr/local/bin/youtube-dl
or this:
wget -O - https://yt-dl.org/downloads/latest/youtube-dl | sudo cat /usr/local/bin/youtube-dl
When I do the former I get this output (I've only taken the last three lines):
Saving to: ‘STDOUT’
- 0%[ ] 0 --.-KB/s in 0,003s
Cannot write to ‘-’ (Success).
And when I do the latter I get the same output just without the "Cannot write to ‘-’ (Success)."
Thanks a ton in advance for any explanation!