0Pricing
Ethical Hacking Academy · Lesson

Parsing Output

grep and cut.

Parsing Output is a free Ethical Hacking Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Ethical Hacking Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Turning Noise into Data

Tools produce walls of text. The skill that makes a recon script useful is parsing - extracting just the IPs, ports, or hostnames you care about.

This lesson focuses on grep and cut, with sort and uniq for cleanup.

Filtering with grep

Start by keeping only the relevant lines. To pull open ports from Nmap output, grep for the word open.

grep 'open' services.txt

grep -o for Exact Matches

grep -o prints only the matching part of each line, not the whole line. Combined with a regex it extracts precise tokens like IP addresses.

grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' scan.txt

cut by Delimiter

cut slices each line into fields by a delimiter and prints the ones you choose. To take a port number from 80/tcp open http, cut on the slash.

echo '80/tcp open http' | cut -d/ -f1   # prints 80

cut by Character Position

cut can also slice by character range with -c, useful for fixed-width output.

echo 'PORT-00443' | cut -c6-10   # prints 00443

Chaining grep and cut

Pipe grep into cut to extract exactly one column from filtered lines - for example, all open port numbers.

grep 'open' services.txt | cut -d/ -f1

Sorting and Deduplicating

sort orders lines and uniq removes adjacent duplicates (so sort first). Add -c to count occurrences.

cut -d' ' -f1 access.log | sort | uniq -c | sort -rn

Parsing Greppable Nmap

Nmap's greppable format (-oG) is built for this. Each host is one line, easy to slice for live hosts.

grep 'Up' hosts.gnmap | cut -d' ' -f2

Substitution with sed and tr

When cut is not enough, sed substitutes patterns and tr translates or deletes characters - for example turning commas into newlines.

echo '80,443,8080' | tr ',' '\n'
sed 's/Nmap scan report for //' hosts.txt

Building a Clean Target List

Put it together: extract live IPs, dedupe, and write a clean file the next tool can consume.

grep 'Up' hosts.gnmap | cut -d' ' -f2 | sort -u > live_hosts.txt

awk for Conditional Columns

When you need logic plus columns, awk combines them. Here it prints only ports above 1023 from a parsed list.

grep 'open' services.txt | awk -F/ '$1 > 1023 {print $1}'

Quick Check

Pick the right field extractor.

Recap

You learned to parse tool output into usable data:

  • grep (and -o) filters and extracts matches.
  • cut slices fields by delimiter or character position.
  • sort | uniq -c orders, dedupes, and counts.
  • Chain them to produce clean target lists for the next tool.

Next: building a complete recon tool.

Frequently asked questions

Is the “Parsing Output” lesson free?

Yes — the full text of “Parsing Output” is free to read here on the web, and the Ethical Hacking Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Ethical Hacking Academy course, upgrade to CoddyKit PRO.

What will I learn in “Parsing Output”?

grep and cut. You practise Ethical Hacking Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Ethical Hacking Academy?

No prior experience is required. Ethical Hacking Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Parsing Output” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Ethical Hacking Academy lesson?

Yes. Every Ethical Hacking Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Script Basics
  2. Automating Recon
  3. Parsing Output
  4. Building a Recon Tool
← Back to Ethical Hacking Academy