Code Monkey home page Code Monkey logo

nmap-grep-ports's Introduction

nmap-grep-ports

Handy bash one liner to grep all port numbers from an Nmap output file and print them to a single line for further scanning.

cat nmap/scan1.nmap | grep -oP '^\d+/tcp' | awk -F/ '{print $1}' | tr '\n' ',' | sed 's/,$/\n/'

Breakdown of the Command:

cat nmap/scan1.nmap: Reads the Nmap output file. grep -oP '^\d+/tcp': Uses grep with Perl-compatible regex (-P) to extract lines starting with port numbers followed by /tcp. awk -F/ '{print $1}': Splits the output by / and prints the first part (the port number). tr '\n' ',': Translates newlines into commas. sed 's/,$/\n/': Uses sed to remove the trailing comma and replace it with a newline.

Example Output:

For the given input, the command will output:

21,22,23,25,53,80,111,139,445,512,513,514,1099,1524,2049,2121,3306,3632,5432,5900,6000,6667,6697,8009,8180,8787,38405,45023,46534,47247

nmap-grep-ports's People

Contributors

d3ndr1t30x avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.