grep, sed & awk Explained + Functions & Arrays in Bash – Offensive Security Ch.3

Опубликовано: 16 Июнь 2026
на канале: CLOVER -X
11
1

⚡ Bash for Offensive Security — Chapter 3: Text Processing & Functions

Chapter 3 is where Bash starts feeling like a real hacking tool. We cover functions to keep your scripts clean and reusable, arrays to handle lists of targets or IPs, and the Holy Trinity of text processing — grep, sed, and awk — to surgically extract data from logs, configs, and command output. Then we chain them all together with pipes.

✅ What you'll learn:
• Writing and calling Bash functions
• Passing arguments to functions using $1, $2...
• Local vs global variables inside functions
• Indexed arrays — declaring, accessing, appending with +=
• Looping through arrays with the @ symbol
• Associative arrays (key-value pairs) with declare -A
• grep — search logs for patterns, -i, -v flags
• sed — find and replace text on the fly
• awk — extract specific columns from structured output
• Chaining commands with pipes |
• Exercise 4: logger.sh — timestamped logging function
• Exercise 5: roster.sh — array + for loop access list
• Exercise 6: One-liner to extract attacker IPs from auth.log

🔧 Tools used: Bash, grep, sed, awk, nano, Ubuntu Terminal

⚠️ DISCLAIMER: Educational and ethical hacking purposes only.


#grep #sed #awk #BashFunctions #BashArrays #OffensiveSecurity #EthicalHacking #LogAnalysis #LinuxForHackers #BashScripting #CyberSecurityTutorial #BashTextProcessing