Skip to content

Instantly share code, notes, and snippets.

@chasgames
Created January 21, 2020 14:35
Show Gist options
  • Save chasgames/bd061a4faa312c3ea8256cd3aac23545 to your computer and use it in GitHub Desktop.
Save chasgames/bd061a4faa312c3ea8256cd3aac23545 to your computer and use it in GitHub Desktop.
### One-liner in bash to expand all subnets and save to new file
while read p; do $(nmap -n -sL $p | awk '/Nmap scan report/{print $NF}' >> allips); done < allipsubnets
### One-liner in bash to get all the IPs and find them in txt file.
### ^ used to find compare IP at starting line, otherwise can pick an IP within IP. e.g. 1.1.1.1 will find 21.1.1.1
while read p; do $(grep -n "^$p" ~/myfolder/*.txt >> output &); done < allips
### for reference ###
#while read p; do $(grep -iRnw ~/myfolder/*.txt --exclude={file1,file2,file3} -e "$p" >> output &); done < allips
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment