wget -q -O - "$@" <url>

redirect wget output to the terminal, instead of a file

By: unixx
2009-04-15 16:10:59

These Might Interest You

  • Will redirect output of current session to another terminal, e.g. /dev/pts/3 Courtesy of bassu, http://www.commandlinefu.com/commands/by/bassu

    script -f /dev/pts/3
    realist · 2009-08-19 07:04:17 0
  • script -f /tmp/foo will place all output of the terminal, including carriage returns, to a file. This file can be tail dash-eff'ed by one or more other terminals to display the information of the main terminal. Good way to share one's screen on short notice. Note: This produces a very accurate output, but that includes depending on the size of your terminal to be the same. You can clear screens or even resize the terminal for others using this function; I use it in conjunction with the "mid" command in my list. Show Sample Output

    script -f /tmp/foo; tail -f /tmp/foo
    robinsonaarond · 2011-11-22 15:16:08 2
  • Ever needed to test firewalls but didn't have netcat, telnet or even FTP? Enter /dev/tcp, your new best friend. /dev/tcp/(hostname)/(port) is a bash builtin that bash can use to open connections to TCP and UDP ports. This one-liner opens a connection on a port to a server and lets you read and write to it from the terminal. How it works: First, exec sets up a redirect for /dev/tcp/$server/$port to file descriptor 5. Then, as per some excellent feedback from @flatcap, we launch a redirect from file descriptor 5 to STDOUT and send that to the background (which is what causes the PID to be printed when the commands are run), and then redirect STDIN to file descriptor 5 with the second cat. Finally, when the second cat dies (the connection is closed), we clean up the file descriptor with 'exec 5>&-'. It can be used to test FTP, HTTP, NTP, or can connect to netcat listening on a port (makes for a simple chat client!) Replace /tcp/ with /udp/ to use UDP instead.

    exec 5<>/dev/tcp/time.nist.gov/13; cat <&5 & cat >&5; exec 5>&-
    tyzbit · 2015-07-30 21:12:38 9
  • the tee command does fine with file names, but not so much with file descriptors, such as &2 (stderr). This uses process redirection to tee to the specified descriptor. In the sample output, it's being used to tee to stderr, which is connected with the terminal, and to wc -l, which is also outputting to the terminal. The result is the output of bash --version followed by the linecount Show Sample Output

    tee >(cat - >&2)
    camocrazed · 2010-07-20 17:22:31 3
  • No need to install additional packages eg: say hello For multiword say how+are+you

    say() { wget -q -U Mozilla -O output.mp3 "http://translate.google.com/translate_tts?tl=en&q=$1"; gnome-terminal -x bash -c "totem output.mp3"; sleep 4; totem --quit;}
    totti · 2011-09-07 19:48:53 0
  • -p parameter tells wget to include all files, including images. -e robots=off you don't want wget to obey by the robots.txt file -U mozilla as your browsers identity. --random-wait to let wget chose a random number of seconds to wait, avoid get into black list. Other Useful wget Parameters: --limit-rate=20k limits the rate at which it downloads files. -b continues wget after logging out. -o $HOME/wget_log.txt logs the output

    wget --random-wait -r -p -e robots=off -U mozilla http://www.example.com
    starchox · 2009-02-17 22:53:07 5

What Others Think

Use -q instead of -o /dev/null
sud0er · 475 weeks and 1 day ago
unixx · 475 weeks and 1 day ago
or you could just: curl <url>
linuxrawkstar · 475 weeks and 1 day ago
I second the curl, it's more common on servers as well - aka portability.
sudopeople · 475 weeks and 1 day ago
yes, this was a command variation for those that are using wget. some like traceroute, others mtr.
unixx · 475 weeks and 1 day ago
To shorten the command a tiny bit: wget -qO- <url> as it wonderfully uses the gnuopts, you don't need those superfluous spaces, and the "$@" only makes sense if this is in a function.
clockworkavian · 475 weeks ago
excellent, thanks! alias wgeto="wget -qO- <url>"
unixx · 475 weeks ago
Great, thanks! I think you should update the top (green) command to clockworkavian's shortened version, then I would vote it up :)
johandicap · 405 weeks and 5 days ago
What's the "$@" good for?
Neo23x0 · 317 weeks and 1 day ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: