为什么将输出重定向到文件会生成一个表?

为什么将输出重定向到文件会生成一个表?

我想设置一个 cron 作业来定期记录测量结果。 USB 记忆棒安装在路由器中:

user@router:/tmp/home/root# uname -a

Linux 路由器 2.6.36.4brcmarm #2 SMP PREEMPT 三月 20 日星期日 16:06:18 EDT 2016 armv7l GNU/Linux

user@router:/tmp/home/root# curl http://THERMOSTAT/tstat/humidity  >> /tmp/mnt/USBstick/CT80_data/C14HumidityData.txt

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    18    0    18    0     0     80      0 --:--:-- --:--:-- --:--:--    83

为什么将输出附加 (>>) 到文件中会产生上表?

不附加时不会生成该表:

curl http://THERMOSTAT/tstat/humidity
{"humidity":51.00}

是否有命令选项来抑制表响应?

答案1

这是卷曲的进度表。从man curl

PROGRESS METER
   curl  normally displays a progress meter during operations, indicating the
   amount of transferred data, transfer speeds and estimated time left,  etc.
   The  progress  meter  displays number of bytes and the speeds are in bytes
   per second. The suffixes (k, M, G, T, P) are 1024 based. For example 1k is
   1024 bytes. 1M is 1048576 bytes.

   curl  displays this data to the terminal by default, so if you invoke curl
   to do an operation and it is about to write data to the terminal, it  dis‐
   ables  the  progress meter as otherwise it would mess up the output mixing
   progress meter and response data.

   If you want a progress meter for HTTP POST or PUT requests,  you  need  to
   redirect  the  response  output  to  a file, using shell redirect (>), -o,
   --output or similar.

   It is not the same case for FTP upload as that operation does not spit out
   any response data to the terminal.

   If  you  prefer  a  progress  "bar"  instead  of  the  regular  meter, -#,
   --progress-bar is your friend. You can also  disable  the  progress  meter
   completely with the -s, --silent option.

相关内容