sed (utility)

sed is an Linux utility or command that can be used to replace string by another string.

Examples

Basic syntax

1
sed -i 's/old-word/new-word/g' *.md

Troubleshooting

sed: 1: “something…”: invalid command code W

Try adding the -e argument explicitly and giving '' as argument to -i:

1
sed -i '' -e 's/..\/src\/components/..\/components/g' *.mdx

sed: content: in-place editing only works for regular files

1
sed -i '' -e "s/oldstr/newstr/g"  `find .* -type f -maxdepth 0 -print`