我做的剧本。
#!/bin/bash
amqBaseURL="http://10.199.199.199:8080"
/usr/bin/wget --http-user=admin --http-password=admin $amqBaseURL/admin/ -O amq1.html
store=`cat amq1.html |sed -n '/Store/{n;p}'|grep -o "[0-9]*"`
echo -e "$store"脚本输出
--2019-01-23 21:25:13-- http://10.199.199.199:8080/admin/
Connecting to 10.199.199.199:8080... connected.
HTTP request sent, awaiting response... 401 Unauthorized
Reusing existing connection to 10.199.199.199:8080.
HTTP request sent, awaiting response... 200 OK
Length: 7363 (7.2K) [text/html]
Saving to: “amq1.htmlâ€
100%[==========================================================================================================>] 7,363 --.-K/s in 0s
2019-01-23 21:25:13 (251 MB/s) - “amq1.html†saved [7363/7363]
0我只需要得到输出值。与每次运行脚本时的整个长度不同,输出只会是。
100我正在为这个脚本运行一个外部调度程序(Zabbix),这个工具只接受数字。
发布于 2019-01-23 22:28:32
张贴答案,以使问题可以被标记为结束。归功于DopeGhoti。为了抑制完整的wget会话输出,可以使用-q或--quiet标志运行该命令。从文件中:
-q --quiet Turn off Wget's output.
或者,要获得最小的输出(例如错误),请使用-nv或--no-verbose标志。从文件中:
-nv --no-verbose Turn off verbose without being completely quiet (use -q for that), which means that error messages and basic information still get printed.
https://unix.stackexchange.com/questions/496322
复制相似问题