Skip to content

Instantly share code, notes, and snippets.

@maximkott
Created February 27, 2015 14:37
Show Gist options
  • Save maximkott/7fd6908aeaa982864b93 to your computer and use it in GitHub Desktop.
Save maximkott/7fd6908aeaa982864b93 to your computer and use it in GitHub Desktop.
Recursively replace a pattern in files
#!/bin/bash
if [ -z "$1" ]; then
echo "mising argument: query"
exit 0
fi
if [ -z "$2" ]; then
echo "mising argument: replace"
exit 0
fi
find . -depth -name "*${1}*" -execdir rename "s/${1}/${2}/g" "{}" \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment