replace string across multiple files with sed

Here’s a useful mac osx / linux trick that helps with replacing a string across multiple files using sed.

I am trying to replace

setApply(“s1”, “parallel”) 


     configApplyParallelization(“s1”, “dynamic-vertex-parallel”)

The command is

sed -i ” ‘s/setApply(\”s1\”, \”parallel\”)/configApplyParallelization(\”s1\”,\”dynamic-vertex-parallel\”)/g’ *.gt

The trick for mac osx is that you need an empty string after the -i, otherwise you get an error message

     extra characters at the end of p command

Only figured this out thanks to this post

I believe you don’t need this on linux, the original post here

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s