Created
October 27, 2012 19:25
-
-
Save okalachev/3965760 to your computer and use it in GitHub Desktop.
Script, that replaces a string in a directory (files/directories names & files content)
This file contains 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 | |
# Script, that replaces a string in a directory (files/directories names & files content) | |
# Usage: hyper-replace what to | |
what=$1 | |
to=$2 | |
for file in `find * -depth` | |
do | |
mv $file `echo $file | sed -r "s/$what([^\/]*)$/$to\1/g"` 2> /dev/null | |
done | |
for file in `find * -type f` | |
do | |
cat $file | sed -r "s/$what/$to/g" > $file | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment