WGET without the log file
You could try -o and -q
-o logfile
--output-file=logfile
Log all messages to logfile. The messages are
normally reported to standard error.
-q
--quiet
Turn off Wget's output.
So you'd have:
wget ... -q -o /dev/null ...
Redirect wget screen output to a log file in bash
Standard output can be redirected to a file in bash using the >>
operator (for appending to the file) or the >
operator (for truncating / overwriting the file). e.g.
echo hello >> log.txt
will append "hello" to log.txt. If you still want to be able to see the output in your terminal and also write it to a log file, you can use tee
:
echo hello | tee.txt
However, wget
outputs most of its basic progress information through standard error rather than standard output. This is actually a very common practice. Displaying progress information often involves special characters to overwrite lines (e.g. to update a progress bar), change terminal colors, etc. Terminals can process these characters sensibly in real time, but it often does not make much sense to store them in a file. For this reason, such kinds of incremental progress output are often separated from other output which is more sensible to store in a log file to make them easier to redirect accordingly, and hence incremental progress information is often output through standard error rather than standard output.
However, you can still redirect standard error to a log file:
wget example.com 2>> log.txt
Or using tee
:
wget example.com 2>&1 | tee log.txt
(2>&1
redirects standard error through standard output, which is then piped to tee
).
How do I request a file but not save it with Wget?
Use q
flag for quiet mode, and tell wget
to output to stdout with O-
(uppercase o) and redirect to /dev/null
to discard the output:
wget -qO- $url &> /dev/null
>
redirects application output (to a file). if >
is preceded by ampersand, shell redirects all outputs (error and normal) to the file right of >
. If you don't specify ampersand, then only normal output is redirected.
./app &> file # redirect error and standard output to file
./app > file # redirect standard output to file
./app 2> file # redirect error output to file
if file is /dev/null
then all is discarded.
This works as well, and simpler:
wget -O/dev/null -q $url
How to hide wget output in Linux?
Why don't you use -q
?
From man wget
:
-q
--quiet
Turn off Wget's output.
Test
$ wget www.google.com
--2015-05-08 14:07:42-- http://www.google.com/
Resolving www.google.com (www.google.com)...
(...)
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html’
[ <=> ] 17,913 --.-K/s in 0.01s
2015-05-08 14:07:42 (1.37 MB/s) - ‘index.html’ saved [17913]
And:
$ wget -q www.google.com
$
How to run wget In background for an unattended download of files?
wget -bqc http://path.com/url.iso
where:
-b: Go to background immediately after startup. If no output file is specified via the -o, output is redirected to wget-log.
-q: Turn off Wget's output (saves some disk space)
-c: Resume broken download i.e. continue getting a partially-downloaded file. This is useful when you want to finish up a download started by a previous instance of Wget, or by another program.
Alternative method:
Use nohup
like this:
nohup wget http://example.com/dvd.iso &
exit
nixCraft
wget command to download a file and save as a different filename
Use the -O file
option.
E.g.
wget google.com
...
16:07:52 (538.47 MB/s) - `index.html' saved [10728]
vs.
wget -O foo.html google.com
...
16:08:00 (1.57 MB/s) - `foo.html' saved [10728]
How to get past the login page with Wget?
Based on the manual page:
# Log in to the server. This only needs to be done once.
wget --save-cookies cookies.txt \
--keep-session-cookies \
--post-data 'user=foo&password=bar' \
--delete-after \
http://server.com/auth.php
# Now grab the page or pages we care about.
wget --load-cookies cookies.txt \
http://server.com/interesting/article.php
Make sure the --post-data
parameter is properly percent-encoded (especially ampersands!) or the request will probably fail. Also make sure that user
and password
are the correct keys; you can find out the correct keys by sleuthing the HTML of the login page (look into your browser’s “inspect element” feature and find the name
attribute on the username and password fields).
Related Topics
In a Bash Script, What Would $'\0' Evaluate to and Why
How to Send Signal from One Program to Another
How to Print Linux Group Names on Multiple Line Instead of Single Line Output
How to Trace a System Call in Linux
How to Tell Binary from Text Files in Linux
Detect If Stdout Is Redirected to a Pipe (Not to a File, Character Device, Terminal, or Socket)
How to Diff Two Sections of The Same File
Getting Function Arguments Using Kprobes
Alternatives to Make for Linux/Freebsd
How Are Posix Threads Implemented on Linux
Can Not Connect to Google Compute Engine via Ssh
What Determines The Order Directory Entries Are Returned by Getdents
Execute a Command in Another Terminal via /Dev/Pts
Using Netcat to Pipe Unix Socket to Tcp Socket