sed
Skill7 starsChanged 10 months agoMITView on GitHub
Expert GNU sed one-liner generation and transformation. Use this skill whenever the user asks to transform text, edit files in-place, refactor code via CLI, process logs, do bulk find/replace, extract lines, delete patterns, or perform any stream editing task. Trigger on keywords like "sed", "replace in files", "find and replace", "edit in place", "strip lines", "extract pattern", "log filtering", "batch rename content", "remove lines matching", "transform output", or any request that maps to a sed one-liner or pipeline. When in doubt, use this skill — sed is often the right tool.
- Reads credentials
1 other project uses a version of this.
Adopted by
Most recently taken up by
- Cogni-AI-OU/cogni-ai-agent-skillstheir own version, first seen May 19, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- Cogni-AI-OU/cogni-ai-agent-skills★ 4same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository30 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- apple-cktool-jsSkill
- apple-cktoolSkill
- audit-training-experimentSkill
- awkSkill
- close-out-ml-experimentSkill
- compare-models-blindlySkill
- conventional-commitsSkill
- design-resumable-model-evaluationSkill
- gogopowermanagerSkill
- ios-design-reviewSkill
- mikrotik-routerosSkill
- obsidian-dailySkill
- orbstack-cliSkill
- package-private-ml-artifactsSkill
- prepare-training-corpusSkill
- proxmox-adminSkill
- review-ios-ui-apple-higSkill
- review-training-data-qualitySkill
- run-hugging-face-training-smokeSkill
- select-and-verify-best-checkpointSkill
- send-to-minionSkill
- swift-reviewSkill
- technical-writerSkill
- tmuxinatorSkill
- topydoSkill
- unhobble-agent-contextSkill
- validate-structured-model-outputSkill
- write-a-promptSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 3 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 16
All output assumes GNU sed (sed --version shows GNU).
- Very specific: line 28
Dry-run first: When editing files, show the sed without -i before the in-place version so the user can verify.
- Distinctive: line 30
Chain with pipes: when sed alone isn't the cleanest tool.
- Very specific: line 181
Use \b for word boundaries (GNU sed supports \b in ERE).
- Distinctive: line 241
When responding to a sed request:
- Very specific: line 244
If editing files in-place, show dry-run first, then the -i version.
- Distinctive: line 245
Add a one-line comment explaining what each part does if non-obvious.
- Very specific: line 246
If the task is better served by awk, perl, jq, or ripgrep, say so briefly and optionally provide that alternative instead.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
GNU sed Skill
All output assumes GNU sed (sed --version shows GNU). POSIX compatibility is
not a goal; use -E (extended regex) by default unless basic regex is clearly
sufficient.
Core Principles
- Prefer one-liners. Multi-line sed scripts are a last resort.
- Use
-Efor extended regex (avoids backslash noise). - Use
-ifor in-place edits; always show the command with a backup suffix suggestion (-i.bak) if the operation is destructive. - Dry-run first. When editing files, show the
sedwithout-ibefore the in-place version so the user can verify. - Chain with pipes when sed alone isn't the cleanest tool.
- Never use sed to parse structured formats (JSON, YAML, XML). Redirect to
jq,yq, orxmllintand say why.
Flags to Always Know
| Flag | Meaning | |
-E | Extended regex (ERE): +, ?, ` | , ()` work without backslash |
-i[SUFFIX] | Edit in place (GNU: -i or -i'' for no backup, -i.bak for backup) | |
-n | Suppress automatic print; use with p to print selectively | |
-e | Multiple expressions in one invocation | |
-f FILE | Read commands from a script file | |
--sandbox | Disallow e, r, w commands (safe mode) |
Command Quick Reference
Substitution (s)
# Basic replace (first occurrence per line)
sed 's/foo/bar/'
# Replace all occurrences on each line
sed 's/foo/bar/g'
# Case-insensitive replace (GNU extension)
sed 's/foo/bar/gI'
# Replace only on lines matching a pattern
sed '/error/s/foo/bar/g'
# Replace on line ranges
sed '10,20s/foo/bar/g'
# Use & to reference the matched text
sed 's/[0-9]\+/(&)/g' # wraps every number in parens
# Capture groups with \1, \2
sed -E 's/(foo)(bar)/\2\1/'
# Delimiter swap (useful when pattern contains /)
sed 's|/usr/local|/opt|g'Delete lines (d)
# Delete lines matching a pattern
sed '/^#/d'
# Delete blank lines
sed '/^[[:space:]]*$/d'
# Delete line range
sed '5,10d'
# Delete from pattern to end of file
sed '/START/,$d'
# Delete lines NOT matching (invert with !)
sed '/keep/!d'Print / Extract (p, -n)
# Print only matching lines (like grep)
sed -n '/error/p'
# Print line numbers with matches
sed -n '/error/='
# Print a line range
sed -n '10,20p'
# Print from pattern to pattern (inclusive)
sed -n '/START/,/END/p'
# Print only the captured group (GNU extension)
sed -En 's/.*key=([^ ]+).*/\1/p'Insert / Append / Change (i, a, c)
# Insert a line before match
sed '/pattern/i\NEW LINE'
# Append a line after match
sed '/pattern/a\NEW LINE'
# Replace the entire matching line
sed '/pattern/c\REPLACEMENT LINE'Transform characters (y)
# Like tr: map chars one-to-one
sed 'y/abc/ABC/'Multi-expression
sed -E -e 's/foo/bar/g' -e 's/baz/qux/g'Patterns & Addresses
/regex/ — lines matching regex
/re1/,/re2/ — line range from re1 to re2 (inclusive)
N — line number N
N,M — line numbers N through M
N~STEP — every STEP lines starting at N (e.g. 1~2 = odd lines)
$ — last line
/re/! — lines NOT matchingCommon Use Cases
Shell scripting: rewrite config values
# Dry-run
sed -E 's/^(TIMEOUT=).*/\1120/' config.env
# In-place with backup
sed -E -i.bak 's/^(TIMEOUT=).*/\1120/' config.envCode refactoring: rename symbol across files
# Preview
grep -rl 'OldClass' src/ | xargs sed -E 's/\bOldClass\b/NewClass/g'
# In-place
grep -rl 'OldClass' src/ | xargs sed -E -i.bak 's/\bOldClass\b/NewClass/g'Use \b for word boundaries (GNU sed supports \b in ERE).
Log processing: extract fields
# Extract timestamps from nginx logs
sed -En 's/.*\[([^\]]+)\].*/\1/p' access.log
# Show only lines between two timestamps (approximate)
sed -n '/2024-01-01 10:00/,/2024-01-01 11:00/p' app.log
# Strip ANSI color codes
sed -E 's/\x1B\[[0-9;]*[mK]//g'File batch editing: add/remove lines
# Add a shebang to all .sh files missing one
find . -name '*.sh' | xargs sed -i '1{/^#!/!i\#!/usr/bin/env bash
}'
# Remove trailing whitespace
sed -E -i 's/[[:space:]]+$//' file.rb
# Comment out lines matching a pattern
sed -i 's/^FEATURE_X=/#FEATURE_X=/' .envDelete lines between markers (exclusive)
sed '/START/,/END/{/START/!{/END/!d}}' file.txtNumber lines (print with line numbers)
sed = file.txt | sed 'N;s/\n/\t/'Combining with Other Tools
# sed + xargs: batch replace in files found by grep
grep -rl 'pattern' . | xargs sed -i 's/pattern/replacement/g'
# sed + awk: sed for line filtering, awk for field extraction
sed -n '/error/p' app.log | awk '{print $1, $NF}'
# sed in a pipeline
cat access.log | sed -n '/POST/p' | cut -d' ' -f7 | sort | uniq -cOutput Format
When responding to a sed request:
- Show the one-liner in a code block, ready to copy-paste.
- If editing files in-place, show dry-run first, then the
-iversion. - Add a one-line comment explaining what each part does if non-obvious.
- If the task is better served by
awk,perl,jq, orripgrep, say so briefly and optionally provide that alternative instead.
Gotchas
- macOS ships BSD sed, not GNU sed.
-irequires a mandatory suffix (-i ''is valid on BSD,-i.bakon both). If the user is on macOS, note this. - Regex in sed is greedy by default; there is no non-greedy quantifier in GNU sed
ERE. Workaround: use negated character classes (
[^x]*instead of.*?). \wis a GNU sed extension, not portable sed. Use[[:alnum:]_]for portable word characters, and[0-9]or[[:digit:]]for digits. Use Perl (perl -pe) when you need PCRE shorthands such as\d.- Multiline matching across line breaks requires the
Ncommand or a hold-space trick. If the user needs real multiline regex, recommendperl -0777 -pe.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

