sed

Verified for current stable LTS

Sed Commands

Sed command syntax with verified terminal examples.

Commands

27 commands for Sed

sed

Sed Command: Custom Delimiter In Sed

<command> | sed '<s#////#____#g>'
sed

Sed Command: Delay File Opening Sed Function W

<command> | sed -fa <path/to/script.sed>
sed

Sed Command: Delay File Opening With Sed Script

<command> | sed -fa <path/to/script.sed>
sed

Sed Command: Delay Opening Files With W Function

<command> | sed -fa <path/to/script.sed>
sed

Sed Command: Delete Blank Lines From File

sed -i '/^[[:space:]]*$/d' <path/to/file>
sed

Sed Command: Delete Lines With Backup File

sed -i.orig '1,5d' <path/to/file>
sed

Sed Command: Execute Script File Sed

<command> | sed -f <path/to/script_file.sed>
sed

Sed Command: Execute Sed Script File

<command> | sed -f <path/to/script.sed>
sed

Sed Command: Execute Sed Script File Output

<command> | sed -f <path/to/script.sed>
sed

Sed Command: Insert Line At Beginning File

sed -i '1i\your new line text\' <path/to/file>
sed

Sed Command: Multiple Substitutions In Sed

<command> | sed -e '<s/apple/mango/g>' -e '<s/orange/lime/g>'
sed

Sed Command: Print First Line

<command> | sed -n '1p'
sed

Sed Command: Print First Line Of Input

<command> | sed -n '1p'
sed

Sed Command: Print First Line Output

<command> | sed -n '1p'
sed

Sed Command: Print First Line Sed

<command> | sed -n '1p'
sed

Sed Command: Print First Line To Stdout

<command> | sed -n '1p'
sed

Sed Command: Replace Apple With Apple Uppercase Extended Regex

<command> | sed -E 's/(apple)/\U\1/g'
sed

Sed Command: Replace Apple With Apple Uppercase Extended Regex Output

<command> | sed -E 's/(apple)/\U\1/g'
sed

Sed Command: Replace Apple With Mango

<command> | sed 's/apple/mango/g'
sed

Sed Command: Replace Apple With Mango Basic Regex

<command> | sed 's/apple/mango/g'
sed

Sed Command: Replace Apple With Mango Basic Regex In Place

sed -i 's/apple/mango/g' <path/to/file>
sed

Sed Command: Replace Apple With Mango Basic Regex Output

<command> | sed 's/apple/mango/g'
sed

Sed Command: Replace Apple With Mango In File Overwrite

sed -i 's/apple/mango/g' <path/to/file>
sed

Sed Command: Replace Apple With Mango In File With Backup

sed -i bak 's/apple/mango/g' <path/to/file>
sed

Sed Command: Replace Text Apple To Mango File

sed -i 's/apple/mango/g' <path/to/file>
sed

Sed Command: Substitute Text Apple To Mango Stdout

<command> | sed 's/apple/mango/g'
sed

Sed Command: Turn On Gnu Regex Extension

<command> | sed -fg <path/to/script.sed>

Suggest a Sed Command

Submit missing workflows, corrections, or verified alternatives for this tool.

FAQ

Coverage: Focused examples for common Sed workflows.

Verified version: current stable LTS.

Verification: Test commands in a disposable workspace and submit notes for edge cases.