February 1st, 2023

Find & Replace in a project

Find and replace using ripgrep and sed

  rg 'YOUR_SERCH_TERMS' <location> -l | xargs sed \
  • -l list all the affected files
  • NOTE: sed does not have full regex support, at least for what I tried, so you cannot use the same pattern as for rg


  rg "import (\w+) from '@components/untitled-icons/(.*)'" \
    src/**/* -l | xargs \
    sed -i '' "s,import \(.*\) from '@components/untitled-icons/\(.*\)',import { \1 } from '@smartfish/icons',g"

Useful Resources

You might also like: