Stupid sed tricks

I just learned that you can use any character, not just the slash (/), for a delimitter when substituting with sed. Most unique characters should work.

This is especially useful when editing streams of file paths.

Here's an example that modifies the path in a playlist:

cat list.m3u | sed 's+/home/aolsen/+~/+'

The +'s worked well as a delimitter here and eliminate the need to quote the /'s

This also works in vi.
--Anton

Leave a Reply

Your email address will not be published. Required fields are marked *