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 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
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 ...
How do I make wget properly quiet?
that should work:
%> wget.exe parameters_here 1> NUL 2> NUL
How do you redirect wget response to standard out?
wget -O - http://whatever.com/page.php > /dev/null
or, if you want to redirect standard error output also:
wget -O - http://whatever.com/page.php > /dev/null 2>&1
or, for codegolf :-)
wget -O-
How can I show the wget progress bar only?
You can use the following filter:
progressfilt ()
{
local flag=false c count cr=$'\r' nl=$'\n'
while IFS='' read -d '' -rn 1 c
do
if $flag
then
printf '%s' "$c"
else
if [[ $c != $cr && $c != $nl ]]
then
count=0
else
((count++))
if ((count > 1))
then
flag=true
fi
fi
fi
done
}
Usage:
$ wget --progress=bar:force http://somesite.com/TheFile.jpeg 2>&1 | progressfilt
100%[======================================>] 15,790 48.8K/s in 0.3s
2011-01-13 22:09:59 (48.8 KB/s) - 'TheFile.jpeg' saved [15790/15790]
This function depends on a sequence of 0x0d0x0a0x0d0x0a0x0d
being sent right before the progress bar is started. This behavior may be implementation dependent.
Hide variable application result from bash output
You can use:
RESULT=`wget --spider http://mysite.com 2>&1`
And this does the trick too:
RESULT=`wget -O wget.tmp http://mysite.com >/dev/null 2>&1`
Played around a little and came up with that one:
RESULT=`curl -fSw "%{http_code}" http://example.com/ -o a.tmp 2>/dev/null`
This outputs nothing but "200" - Nothing else.
wget and run/remove bash script in one line
I think you might need to actually execute it:
wget http://sitehere.com/install.sh -v -O install.sh; ./install.sh; rm -rf install.sh
Also, if you want a little more robustness, you can use &&
to separate commands, which will only attempt to execute the next command if the previous one succeeds:
wget http://sitehere.com/install.sh -v -O install.sh && ./install.sh; rm -rf install.sh
How do I suppress output from this Shell command
First both stdout(1) and stderr(2) point to your terminal.
You then redirect stderr to whatever your stdout points to. (Which is the terminal.)
Afterwards you redirect stdout to /dev/null
. But stderr still points to the terminal.
You can do it the other way around >/dev/null 2>&1
: This way you first redirect stdout to /dev/null
and then stderr to the same.
Bash provides the shorthand &>/dev/null
for this.
Related Topics
Checking for Installed Packages and If Not Found Install
Flex Development on Linux, What's a Good Free Environment
Can't Close a Scpi(Telnet) Session with Echo "^]" When I Use It in a Script
Testing Out of Disk Space in Linux
Startup Script with Systemd in Linux
How to Learn the Structure of Linux Wireless Drivers (Mac80211)
Lowering Linux Kernel Timer Frequency
Add Double Quotes Around Fields in Awk Script Output
Stracing to Attach to a Multi-Threaded Process
Installing Openssh on the Alpine Docker Container
Linux Kernel Interrupt Handler Mutex Protection
Creating Binary with Cmake Removes Runtime Path
How to Understand "Cmpl $0X0, -0X30(%Rbp)"/"Je ..."