【发布时间】:2016-12-17 01:24:48
【问题描述】:
我是 shell 脚本的新手,这是我的问题:
我想将airmon-ng check 的输出中的 PID 存储到一些变量(例如:$1、$2、$3),以便我可以执行kill $1 $2 $3。
这是airmon-ng check 的示例输出:
Found 3 processes that could cause trouble.
If airodump-ng, aireplay-ng or airtun-ng stops working after
a short period of time, you may want to kill (some of) them!
PID Name
707 NetworkManager
786 wpa_supplicant
820 dhclient
我要获取数字 707、786、820。
我尝试使用set 'airmon-ng check',然后使用 for 循环:
set `airmon-ng check`
n=$#
for (( i=0; i<=n; i++ ))
do
echo $i
done
它输出 1,2,3,...36 不是文字或数字,所以我不知道该怎么做。
【问题讨论】:
-
我认为会有更好的方法来做到这一点,但我想不通。所以任何方式都可以接受:)
标签: linux bash shell io scripting