想要改进这个问题? Update the question所以它是on-topic堆栈溢出。
关闭 10 年前。
我正在使用 Wget 向新的 Web 服务器发出 http 请求。我这样做是为了加热 MySQL 缓存。我不想在提供文件后保存文件。
wget -nv -do-not-save-file $url
我可以用 wget 做类似 -do-not-save-file
的事情吗?
最佳答案
使用 q
标志用于安静模式,并告诉 wget
使用 O-
(大写 o)输出到标准输出并重定向到 /dev/null
丢弃输出:
wget -qO- $url &>/dev/null
>
将应用程序输出重定向(到文件)。如果 >
前面有 & 符号,shell 会将所有输出(错误和正常)重定向到 >
的文件右侧。如果不指定 & 符号,则只会重定向正常输出。
./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
则全部丢弃。
这同样有效,而且更简单:
wget -O/dev/null -q $url
https://stackoverflow.com/questions/9691367/