Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 是否使用nmap在每个ip上循环?_Bash_Loops_Nmap - Fatal编程技术网

Bash 是否使用nmap在每个ip上循环?

Bash 是否使用nmap在每个ip上循环?,bash,loops,nmap,Bash,Loops,Nmap,我正在寻找一种方法来清理nmap的输出,并在每个ip上循环运行ssh pi@,直到找到匹配项为止。这可能吗?我一直在四处搜索,但我找不到任何有人在nmap输出上循环的案例 最接近我的是: ➜ nmap -n -sP xxx.xxx.x.13/24 | grep "Nmap scan report for" Nmap scan report for xxx.xxx.x.1 Nmap scan report for xxx.xxx.x.2 Nmap scan report f

我正在寻找一种方法来清理nmap的输出,并在每个ip上循环运行
ssh pi@
,直到找到匹配项为止。这可能吗?我一直在四处搜索,但我找不到任何有人在nmap输出上循环的案例

最接近我的是:

➜ nmap -n -sP xxx.xxx.x.13/24 | grep "Nmap scan report for"  
Nmap scan report for xxx.xxx.x.1
Nmap scan report for xxx.xxx.x.2
Nmap scan report for xxx.xxx.x.6
Nmap scan report for xxx.xxx.x.7
Nmap scan report for xxx.xxx.x.9
Nmap scan report for xxx.xxx.x.10
Nmap scan report for xxx.xxx.x.11
Nmap scan report for xxx.xxx.x.13
Nmap scan report for xxx.xxx.x.19
Nmap scan report for xxx.xxx.x.22
我正在寻找一种方法来清理nmap的输出

并在每个ip上循环运行ssh pi@,直到找到匹配项。这可能吗

也许读一会儿

#/usr/bin/env bash
读时-ru9ips;做
ssh“pi@$ips”
完成9<
nmap -n -sP xxx.xxx.x.13/24 | awk '/^Nmap scan report for [[:digit:].]+$/ {print $NF}'