Last active
August 29, 2015 14:07
-
-
Save r8or0pz/250b1a44afbd27b1a1fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
search="$1" | |
replace="$2" | |
target_dir="$3" | |
[ -n "$search" ] || \ | |
{ echo "search is empty"; exit 1; } | |
[ -n "$replace" ] || \ | |
{ echo "replace is empty"; exit 1; } | |
[ -n "$target_dir" ] || \ | |
{ echo "target_dir is empty"; exit 1; } | |
[ -d "$target_dir" ] || \ | |
{ echo "\"$target_dir\" directory is missing"; exit 1; } | |
grep -rl "$search" "$target_dir" | \ | |
xargs sed -i "s/$search/$replace/g" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment