Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 08-04-2007, 09:48 PM   #1
LQ Newbie
Registered: Jan 2007
Posts: 6

Rep: Reputation: 0
A little help with redirecting output

Can someone help explain to me how I can pull certain information out of a file and direct it towards a newer one. I've seen the commands: "sed, grep, awk and cat" and know it has something to do with them. But I just can't seem to find the answers that I'm looking for. What I'm wanting to do is take the output from a nmap scan and only foward the IP listed in there that have open specified ports to another file. This way the list of IP can be used for other programs. He's an example of what Im looking for:

Starting Nmap 4.20 ( ) at 2007-08-04 20:45 CDT
Interesting ports on neptune (
Not shown: 1694 filtered ports
21/tcp  open  ftp
139/tcp open  netbios-ssn
445/tcp open  microsoft-ds

Nmap finished: 1 IP address (1 host up) scanned in 32.021 seconds
Then filter out those results via a script or something to only list the IP of hosts that have port 21 open

Old 08-04-2007, 11:08 PM   #2
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678
Could you post a sample input that has more than one target found?

sed -f nmap.sed nmapsamp
Inside a range between "Interesting" and a blank line, if it is the "Interesting"... line, the line is replaced with the IP address and saved in the Hold register. If a line starts with "21/tcp", the Hold register is retrieved and printed.

Last edited by jschiwal; 08-04-2007 at 11:13 PM.


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
redirecting output using > cmk77 Slackware 8 11-10-2006 03:08 AM
Redirecting sh output to a pipe elmafiacs Programming 0 05-10-2006 02:55 PM
Redirecting output into a filename pbickerd Linux - Software 10 02-24-2006 03:41 PM
Redirecting mplayer output driptray Linux - Software 1 10-12-2004 08:42 AM
redirecting xmms output durden2.0 Linux - Software 0 03-06-2004 08:29 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:24 AM.

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