Hi, I posted here before for adding up of datafile name each time, here is an example:
#!/bin/bash
cutdfname="data11.dbf"
newname=$(echo "${cutdfname}" |tr "[A-Z]" "[a-z]" |tr "[a-z]#_@-" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" |tr -s "x")
num=$(echo $newname |cut -d"." -f1|awk -F"x" '{print $NF}')
if [ -z "${num}" ] ; then
num=1
newnum=$((num+1))
finaldfname=$(echo $cutdfname|sed -e "s/\./$newnum\./g")
else
newnum=$((num+1))
finaldfname=$(echo $cutdfname|sed -e "s/$num\./$newnum\./g")
fi
echo "$cutdfname -> $finaldfname"
fulldfname=$lastdf/$finaldfname
echo "fulldfname is $fulldfname"
./cal_file_name.bsh
data11.dbf -> data12.dbf
fulldfname is /data12.dbf
but it failed only if datafile name like: 09
for example:
#!/bin/bash
cutdfname="data09.dbf"
newname=$(echo "${cutdfname}" |tr "[A-Z]" "[a-z]" |tr "[a-z]#_@-" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" |tr -s "x")
num=$(echo $newname |cut -d"." -f1|awk -F"x" '{print $NF}')
if [ -z "${num}" ] ; then
num=1
newnum=$((num+1))
finaldfname=$(echo $cutdfname|sed -e "s/\./$newnum\./g")
else
newnum=$((num+1))
finaldfname=$(echo $cutdfname|sed -e "s/$num\./$newnum\./g")
fi
echo "$cutdfname -> $finaldfname"
fulldfname=$lastdf/$finaldfname
echo "fulldfname is $fulldfname"
./cal_file_name.bsh
./cal_file_name.bsh: 09: value too great for base (error token is "09")
data09.dbf ->
fulldfname is /
can someone tune it to be perfect?
Thank you and have a nice weekend!