Getting a list of active addresses in your own network.

nmap -n -sP -oG - 10.10.10.*/32 | grep ": Up" | cut -d' ' -f2
You can substitute 10.10.10.* by your own network. Or whatever nmap accepts, inlcluding submask.
Sample Output
10.10.10.2
10.10.10.4
10.10.10.20
10.10.10.130
10.10.10.200
10.10.10.254

0
2012-08-13 15:37:21

What Others Think

kormoc@Bender: ~ > `nmap -n -sP -oG - ${sSRC} | grep \": Up\" | cut -d' ' -f2` grep: Up": No such file or directory kormoc@Bender: ~ > `nmap -n -sP -oG - ${sSRC} | grep ": Up" | cut -d' ' -f2` WARNING: No targets were specified, so 0 hosts scanned.
emtmA · 474 weeks and 5 days ago
why not just doing it without nmap? ifconfig | awk '/inet / {print $2}'
chrismccoy · 474 weeks and 4 days ago
@chrismccoy: probably because that gives active addresses on your host while the nmap command lists active hosts on your network.
TheMightyBuzzard · 474 weeks and 4 days ago
@kormoc: sorry if my question will sound stupid but are you sure $sSRC has a value?
scanepa · 474 weeks and 4 days ago
Ahh, I misunderstood and assumed it was some nmap magic.
emtmA · 474 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: