I think that the following KornShell script does the job
#!/bin/ksh
function substring
{
TOKEN=$1
LENGTH=${#TOKEN}
COUNTER=0
typeset -L1 CURRENT_CHARACTER
RESULT=""
while (( COUNTER < LENGTH ))
do
CURRENT_CHARACTER=$TOKEN
if [[ $CURRENT_CHARACTER = "_" ]]
then
if (( (COUNTER + 1) < LENGTH ))
then
if [[ ${TOKEN#?} = [0-9] ]]
then
print "$RESULT"
fi
else
RESULT="$RESULT$CURRENT_CHARACTER"
fi
else
RESULT="$RESULT$CURRENT_CHARACTER"
fi
(( COUNTER = COUNTER + 1 ))
TOKEN=${TOKEN#?}
done
}
INPUT_FILE=$1
OUTPUT_FILE=$1_temp
if [[ -a $OUTPUT_FILE ]]
then
rm $OUTPUT_FILE
fi
cat $INPUT_FILE > $OUTPUT_FILE
while read LINE
do
for TOKEN in $LINE
do
if [[ $TOKEN = *_[0-9] ]]
then
print -n "$(substring $TOKEN) "
else
print -n "$TOKEN "
fi
done
print ""
done < $INPUT_FILE > $OUTPUT_FILE
I tested it with the following input file:
create fil23456 read on 3345
create fil23456_1 read on 34567
create fil23456_2 read on 36789
create fil11111_ read on 36789
create fil22222_5 read on 36789
Which provided the following putput
create fil23456 read on 3345
create fil23456 read on 34567
create fil23456 read on 36789
create fil11111_ read on 36789
create fil22222 read on 36789
Atlast i got suceeded with this
sed '/:./s/^/#/g;
s/\(\) _./\1/;
s/#create filS./alter filS/g'
Input is this
create fil23456 read on 3345
create fil23456_1 read on 34567
create fil23456_2 read on 36789
create fil26756 read on 56890
create fil26756_1 read on 37897
create fil26756_2 read on 67667
and this is the output
create fil23456 read on 3345
alter filS3456 read on 34567
alter filS3456 read on 36789
create fil26756 read on 56890
alter filS6756 read on 37897
alter filS6756 read on 67667
Thanks a lot for all your help...