mirror of
https://github.com/drasko/codezero.git
synced 2026-01-12 02:43:15 +01:00
Added word replace tool
This commit is contained in:
22
tools/replace_words
Executable file
22
tools/replace_words
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
original=(a b c d)
|
||||
replacement=(w x y z)
|
||||
|
||||
# Test that we have both arguments
|
||||
if [ -z "$1" ]; then
|
||||
echo Usage: replace_words ORIGINAL REPLACEMENT
|
||||
exit
|
||||
fi
|
||||
|
||||
for ((i=0;i<1;i++));
|
||||
do
|
||||
|
||||
orig=${original[$i]}
|
||||
repl=${replacement[$i]}
|
||||
echo $orig to $repl
|
||||
for filename in `find $1 -name '*.[ch]'`
|
||||
do
|
||||
sed -i -e "s/$orig/$repl/g" $filename
|
||||
done
|
||||
done
|
||||
Reference in New Issue
Block a user