Hi
I'm trying to finish a script to replace a certain text in a file.
I 'm controlling for the metacharacters, however now there s a problem with "!".
The script is below. The problem I've faced is that if the string i entered is as:
"string! string! string!"
there aren't any problems. However if the string is as:
"string!string!string!"
i get the followin error:
-bash: !string!string": event not found
What can I do to make sure that the script works even if I enter
"string!string!string!"
#!/usr/bin/ksh
$PATH=...
kalacak_1=`grep "RSP_GENERIC_QUERY_123_0_DEFAULT_TURKCE_KONTOR_SUCCESS" $PATH/responses.properties | awk -F* '{print $1}'`
kalacak_2=`grep "RSP_GENERIC_QUERY_123_0_DEFAULT_TURKCE_TL_SUCCESS" $PATH/responses.properties | awk -F* '{print $1}'`
gidecek_1=`grep "RSP_GENERIC_QUERY_123_0_DEFAULT_TURKCE_KONTOR_SUCCESS" $PATH/responses.properties | awk -F* '{print ($NF)}'`
gidecek_2=`grep "RSP_GENERIC_QUERY_123_0_DEFAULT_TURKCE_TL_SUCCESS" $PATH/responses.properties | awk -F* '{print ($NF)}'`
kontrol=`echo $1 | grep '[^ 0-9A-Za-z.,!]' | wc -l`
usage(){
echo "USAGE : ./sample_script.sh "text_to_enter""
}
if (( $# == 1 ))
then
karakter_sayisi=`echo $1 | wc -c`
if [ $karakter_sayisi -le 160 ]
then
if [ $kontrol -eq 0 ]
then
cp $PATH/responses.properties $PATH/responses.properties.$(date '+%d%m%y').$(date '+%H%M')
sed -e "s/$gidecek_1/$1/g" $PATH/responses.properties >> $PATH/responses.properties_yeni
mv $PATH/responses.properties_yeni $PATH/responses.properties
else
echo "Girdiginiz cumle metacharacter icermektedir. Sadece harf,sayi ve .,! kullaniniz"
exit
fi
else
echo "160 karakterden kisa bir metin girmelisiniz."
exit
fi
else
usage
exit
fi