Production-grade text processing - grep, sed, awk, regex
Master text manipulation with grep, sed, awk, and regex for searching, transforming, and processing files. Use this when you need to search logs, filter data, extract patterns, or transform text in files and pipelines.
/plugin marketplace add pluginagentmarketplace/custom-plugin-bash-shell/plugin install custom-plugin-bash-shell@pluginagentmarketplace-bash-shellThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/config.yamlassets/schema.jsonreferences/GUIDE.mdreferences/PATTERNS.mdscripts/validate.pyMaster text manipulation with grep, sed, awk, and regular expressions
After completing this skill, you will be able to:
# Basic search
grep 'pattern' file.txt
grep -i 'pattern' file.txt # Case insensitive
grep -v 'pattern' file.txt # Invert match
grep -n 'pattern' file.txt # Line numbers
grep -c 'pattern' file.txt # Count only
# Extended regex
grep -E 'pat1|pat2' file.txt
grep -E '^start.*end$' file.txt
# Recursive search
grep -r 'pattern' ./
grep -rn --include='*.py' 'def ' ./
# Substitution
sed 's/old/new/' file # First match
sed 's/old/new/g' file # All matches
sed -i 's/old/new/g' file # In-place
# Line operations
sed -n '5p' file # Print line 5
sed '5d' file # Delete line 5
sed '/pattern/d' file # Delete matching
# Multiple operations
sed -e 's/a/b/' -e 's/c/d/' file
# Field processing
awk '{print $1}' file # First field
awk -F: '{print $1}' file # Custom delimiter
awk '{print $NF}' file # Last field
# Patterns
awk '/pattern/' file # Match lines
awk '$3 > 100' file # Condition
# Calculations
awk '{sum+=$1} END{print sum}' file
awk 'NR>1 {total++} END{print total}' file
# Metacharacters
. # Any character
^ # Start of line
$ # End of line
* # Zero or more
+ # One or more (ERE)
? # Zero or one (ERE)
# Character classes
[abc] # Any of a, b, c
[^abc] # Not a, b, c
[a-z] # Range
\d # Digit (PCRE)
\w # Word char (PCRE)
\s # Whitespace (PCRE)
# Count requests by IP
awk '{print $1}' access.log | sort | uniq -c | sort -rn
# Find errors
grep -E 'ERROR|FATAL' app.log | tail -20
# Extract timestamps
grep 'ERROR' app.log | sed 's/.*\[\([^]]*\)\].*/\1/'
# CSV to TSV
sed 's/,/\t/g' data.csv
# JSON value extraction
grep -oP '"name":\s*"\K[^"]+' data.json
# Remove blank lines
sed '/^$/d' file.txt
| Don't | Do | Why |
|---|---|---|
cat file | grep | grep pattern file | Useless use of cat |
| Multiple sed calls | Single sed with -e | Reduces overhead |
grep -E ".*" | Omit if not needed | Slower with regex |
| Error | Cause | Fix |
|---|---|---|
Invalid regex | Bad pattern | Escape special chars |
No match | Wrong case | Use -i flag |
sed delimiter | / in pattern | Use # or | |
# Test regex online
# https://regex101.com/
# Print matched groups
echo "test" | sed -n 's/\(.*\)/\1/p'
# Debug awk
awk '{print NR, NF, $0}' file
# Use ripgrep for speed
rg 'pattern' --type py
# Set locale for speed
LC_ALL=C grep 'pattern' file
# Limit output
grep -m 10 'pattern' file
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.