linux - 如何请求文件但不使用 Wget 保存?

我正在使用 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/

相关文章:

python - 什么是 "first-class"对象?

python - sum() 之类的函数是什么,但用于乘法?产品()?

bash - 为什么 $$ 返回与父进程相同的 id?

python - 为什么提早返回比其他方法慢?

python - 在列表中查找属性等于某个值的对象(满足任何条件)

linux - 否定 bash 脚本中的 if 条件

linux - 在管道 grep 到 grep 后保留颜色

linux - 如何更改 bash 历史完成以完成已经上线的内容?

linux - 使用 Unix 排序对多个键进行排序

python - 使用 groupby 获取组中具有最大值的行