LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-12-2014, 11:58 AM   #1
fac3l3ss
LQ Newbie
 
Registered: Jun 2014
Posts: 2

Rep: Reputation: Disabled
cutting lines from nmap output


Just trying to scan my own subnet and get all IPs/hostnames that return something.

I was using something like:

Code:
nmap -sL -oG - 192.168.1.0/24 |  awk '/Host/{print $2 " " $3}' | awk 'BEGIN{FIELDWIDTHS="16"} {print $1 " " $2}'
But that will return even the ones that were not alive with something like:

192.168.1.200 ()

Basically I need a way to cut the lines that do not have a hostname with them or any line that has a certain number of chars. Can this be done with the regular cut or do I need a script to run something at this level?
 
Old 06-12-2014, 01:05 PM   #2
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Quote:
Originally Posted by fac3l3ss View Post
Basically I need a way to cut the lines that do not have a hostname with them or any line that has a certain number of chars. Can this be done with the regular cut or do I need a script to run something at this level?
Can you post a snippet of the ndmp cmd output and also result you want. If you need to sort IPs which having a hostname, and leave IPs that do not have a hostname associated, then it can be done. Consider if-else with awk.
 
Old 06-12-2014, 01:07 PM   #3
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,773
Blog Entries: 1

Rep: Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339
You can ignore lines with () in them...

Code:
nmap -sL -oG - 8.8.8.0/24 | grep -v '()'
 
Old 06-12-2014, 01:34 PM   #4
fac3l3ss
LQ Newbie
 
Registered: Jun 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
ah, that was it. I couldn't remember how you could use a word or phrase and then leave that out.

Thanks szboardstretcher!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cutting fields from lines with multiple spaces 915086731 Linux - Software 6 09-07-2011 10:51 AM
generate xml from nmap output shourya21 Linux - Newbie 1 01-24-2008 09:54 AM
Vi question. Cutting a specific lines blackzone Linux - General 1 07-19-2006 07:10 PM
Could someone please explain this nmap output? stardotstar Linux - Networking 0 02-07-2005 11:02 PM
Is this site secure (nmap output)? Erik Thorsson Linux - Security 14 10-24-2004 03:44 PM


All times are GMT -5. The time now is 04:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration