如何请求文件,但不使用Wget保存文件? [英] How do I request a file but not save it with Wget?
问题描述
我正在使用Wget向新的Web服务器发出http请求.我这样做是为了预热MySQL缓存.提供文件后,我不想保存文件.
I'm using Wget to make http requests to a fresh web server. I am doing this to warm the MySQL cache. I do not want to save the files after they are served.
wget -nv -do-not-save-file $url
我可以用wget做类似-do-not-save-file
的事情吗?
Can I do something like -do-not-save-file
with wget?
推荐答案
将q
标志用于安静模式,并告诉wget
使用O-
(大写o)输出到stdout并重定向到/dev/null
放弃输出:
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
>
将应用程序输出重定向到文件.如果>
前面跟有&号,则Shell会将所有输出(错误和正常)重定向到>
的文件权限.如果您未指定&"号,则仅重定向普通输出.
>
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
如果文件是/dev/null
,则全部丢弃.
if file is /dev/null
then all is discarded.
这也很好,也更简单:
wget -O/dev/null -q $url
这篇关于如何请求文件,但不使用Wget保存文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!