Ready, sed, go
The sed (stream editor) command combines search and transform in one command.
You can match patterns in text using
RegEx like grep.
But instead of highlighting matches, it is used to transform matches.
Create a file for demonstration:
cat > unix-philosophy.txt << EOF
Write programs that do one thing and do it well.
Write programs to work together.
Write programs to handle text streams, because that is a universal interface.
EOF
Use sed to change the text.
cat unix-philosophy.txt | sed 's/Write/Vibe code/'
It’s a joke
Or we can let sed read the file directly.
sed 's/Write/Vibe code/' unix-philosophy.txt
Output to a file.
sed 's/Write/Vibe code/' unix-philosophy.txt > mcp-manifest.txt
Or change the file directly.
sed -i 's/text/json/' mcp-manifest.txt
We can make it quite when a match is found.
sed '/work/q' unix-philosophy.txt
Delete a word.
sed 's/well//' mcp-manifest.txt
Or delete a line.
sed '/well/d' mcp-manifest.txt
Some transforms can be combined.
sed 's/Write/Vibe code/ ; /well/d' unix-philosophy.txt
Text can be appended.
sed 'aIt''s a joke' mcp-manifest.txt
You can learn more about sed
here.