Index of every page on this site: llms.txt
All skills
Run it yourself

Stream editor for text substitution, line operations, and file transformations.

  • 1 file
  • 2.6 KB
  • Updated 10 months ago
  • GitHub
Use this Skill: https://skilld.dev/gh/jyasuu/cheat-sheet/sed

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈21 tokens for metadata: the name and description. ≈644 when used: this file.

Description uses 1.1% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈85 characters, or 1.1%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

sed — Stream Editor

Basic Substitution

# Replace all occurrences of "day" with "night"
sed 's/day/night/g' file.txt

# Replace first occurrence per line
sed 's/day/night/' file.txt

# Preview substitution without changes
sed 's/Name=Xfce Session/Name=Xfce_Session/' FILE

# Edit file in-place
sed -i 's/day/night/g' file.txt

# Edit with backup
sed -i.bak 's/day/night/g' file.txt

Special Characters & Delimiters

# Escape slashes in paths
sed -i 's/\/path\/to\/somewhere\//\/path\/to\/anotherplace\//' FILE

# Use pipe as delimiter to avoid escaping slashes
sed -i 's|/path/to/somewhere/|/path/to/anotherplace/|' FILE

# Replace tabs with 4 spaces
sed -i 's/\t/    /g' FILE

Line Operations

# Print 2nd line
sed -n '2p' FILE

# Print lines from 2 to 9
sed -n '2,9p' FILE

# Print last line
sed -n '$p' FILE

# Print line 5 and quit
sed -n '5{p;q}' FILE

# Print and quit at 3rd line
sed -n 'p;3q'

# Print lines starting from pattern until line 17
sed -n '/any/,17p' FILE

# Print between two patterns
sed -n '/strstart/,/strend/p' FILE

Line Endings

# Convert CRLF to LF (Windows to Linux)
sed -i 's/\r$//g' FILE

# Convert LF to CRLF (Linux to Windows)
sed -i 's/$/\r/' FILE

# Remove carriage return (original example)
sed -i 's/\r//g' FILE

Whitespace & Formatting

# Remove trailing spaces
sed -i -E "s/\s+$//g" FILE

# Remove leading spaces
sed -i -r 's/^\s+//g' FILE

# Remove empty lines
sed -i -E "/^\s*$/d" FILE

# Remove both leading and trailing spaces
sed -i -E 's/^\s+|\s+$//g' FILE

Advanced Transformations

# Rearrange date format YYYY-MM-DD to DD-MM-YYYY
echo '2024-01-22' | sed -E "s/([0-9]{4})-([0-9]{2})-([0-9]{2})/\3-\2-\1/"

# Anonymize MAC addresses
ifconfig | sed -E "/ether s/([0-9a-f]{2}:{0,1}){6}/00:00:00:00:00:00/g"

# Delete specific lines
sed -i '/pattern_to_match/d' file.txt

# Insert line before matching
sed -i '/pattern/i\New line text' file.txt

# Append line after matching
sed -i '/pattern/a\New line text' file.txt

Multiple Commands

# Multiple substitutions
sed -i -e 's/foo/bar/g' -e 's/baz/qux/g' file.txt

# Use semicolon for multiple commands
sed -i 's/a/b/; s/c/d/' file.txt

# Read commands from file
sed -i -f script.sed file.txt

In-Place Examples

# Delete lines 1-5
sed -i '1,5d' file.txt

# Delete lines containing "pattern"
sed -i '/pattern/d' file.txt

# Delete blank lines
sed -i '/^$/d' file.txt

# Replace in all .txt files
find . -name "*.txt" -exec sed -i 's/old/new/g' {} \;

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at d3e2684. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 10 months ago

README badge

README badge for jyasuu/cheat-sheet/sed