Search This Blog

sed replace string in a file contains slash

sed -i "" "s|AAA/BBB|AAA/CCC|g" input-file.txt
or
sed -i ".bak" "s|AAA/BBB|AAA/CCC|g" input-file.txt

Note:

  • We want in place update to the file, so we need --in-place or -i option, and on Mac OS, the in place extension/suffix must be supplied even if it is a empty string: -i ""
  • We cannot use / as the delimiter

No comments:

Post a Comment