Skip to content

Instantly share code, notes, and snippets.

@bsa7
Last active March 7, 2016 11:15
Show Gist options
  • Save bsa7/dfb83e680b45714f70ff to your computer and use it in GitHub Desktop.
Save bsa7/dfb83e680b45714f70ff to your computer and use it in GitHub Desktop.
recursive find occuriences in files and replace it by regex with sed in bash
  1. Replace text in one file:
    sed 's/regular_expression_or_string_replace_from/string_replace_to/g' source.sql > target.sql
  1. find all files in current folder and replace text in each:
    ls | xargs -I@ sed -i 's/regular_expression_or_string_replace_from/string_replace_to/g' @
  1. find recurcive from current folder all files by mask and replace:
    find '.' | xargs -I@ sed -i 's/regular_expression_or_string_replace_from/string_replace_to/g' @
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment