-
-
Save no1fushi/724f2f370478f3b939aef6cb317a8e80 to your computer and use it in GitHub Desktop.
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 | |
if [ $# -eq 3 ]; then | |
arg=($1 $2 $3) | |
ows=0 | |
elif [ $# -eq 4 ]; then | |
arg=($1 $2 $3 $4) | |
ows=1 | |
else | |
ows=2 | |
fi | |
while : ; do | |
if [ $ows -eq 0 ] ; then | |
sed -i -e 's/'${arg[0]}'/'${arg[1]}'/' ${arg[2]} | |
break | |
elif [ $ows -eq 1 ] ; then | |
sed -e 's/'${arg[0]}'/'${arg[1]}'/g' ${arg[2]}> ${arg[3]} | |
break | |
else | |
read -p "置換対象の文字列: " arg[0] | |
read -p "置換先の文字列: " arg[1] | |
read -p "対象とするファイル: " arg[2] | |
read -p "保存するファイル名(上書き保存の場合空欄): " arg[3] | |
[ -n "${arg[3]}" ] && ows=1 || ows=0 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment