- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Parsing a file (NMAP output) (grep)
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2014 11:14 AM
12-22-2014 11:14 AM
Parsing a file (NMAP output)
We are trying catalog our servers that have port 443 open, so we can catalog where we have used certificates.>
I have multiple files where i have entries in the files containing specific nmap output
Interesting ports on moodle.OURDOMAIN.TLD (XXX.YYY.ZZZ.CCCC):
PORT STATE SERVICE
443/tcp open https
MAC Address: AA:BB:CC:DD:EE:FF (VMWare)
Interesting ports on moodletest.OURDOMAIN.TLD (XXX.YYY.ZZZ.BBB):
PORT STATE SERVICE
443/tcp open https
MAC Address: AA:BB:CC:DD:EE:FF(VMWare)
Interesting ports on moodlew2.OURDOMAIN.TLD(XXX.YYY.ZZZ.AAA):
PORT STATE SERVICE
443/tcp open https
MAC Address: AA:BB:CC:DD:EE:FF (VMWare)
I would like to "grep for the word "open" and grab the two lines prior and line after the occurance of "open"
Hoping the script gurus have an idea.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2014 11:30 AM - edited 12-22-2014 11:30 AM
12-22-2014 11:30 AM - edited 12-22-2014 11:30 AM
Re: Parsing a file (NMAP output) (grep)
>I would like to "grep for the word "open" and grab the two lines prior and line after the occurrence of "open"
No need to script, it's built into grep:
grep -B2 -A1 open input-file