Created
October 23, 2008 06:34
-
-
Save liquidz/18937 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/sh | |
| # script for replacing multiple files | |
| # | |
| # usage: ./replace.sh [directory] [filter] [before] [after] | |
| # | |
| # ex) replace "e" to "a" for all htm/html file in current dir | |
| # # ./replace . 'html?$' e o | |
| if [ $# -eq 0 ] | |
| then | |
| echo "usage: ./replace.sh [directory] [filter] [before] [after]" | |
| echo "" | |
| echo "ex) replace 'e' to 'a' for all htm/html file in current dir" | |
| echo " # ./replace . 'html?$' e o" | |
| else | |
| list=`find $1 | egrep -e $2` | |
| for file in ${list[@]} | |
| do | |
| sed s/$3/$4/g $file > "$file.tmp" | |
| mv $file "$file.back" | |
| mv "$file.tmp" $file | |
| done | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment