Thursday, 22 May 2014

Converting Special Character in Unix Shell Script

#!/bin/ksh
##########################################################################
#
# Parameters
# 1 = Batch file name
##########################################################################
PROGRAM_NAME=`basename $0`
echo $PROGRAM_NAME "has started"
echo " "
########################################
# Concurrent Program parameters #
########################################
#total_args=`echo $*|awk '{print NF}'`
##############
# File Name #
##############
BATCH_FILE=`echo $*|awk '{print $9}' | sed 's/"//g'`
BATCH_FILE=`eval "echo $BATCH_FILE"`
echo "Batch file = " ${BATCH_FILE}
###################
# Data Directory #
###################
DATA_DIR=`echo $*|awk '{print $10}' | sed 's/"//g'`
DATA_DIR=`eval "echo $DATA_DIR"`
echo "Data Dir = " ${DATA_DIR}
############################
# Environmental variables. #
############################
START_TIME=`date +%d-%b-%Y" "%H:%M`
HOST_NAME=`uname -n`
TSTAMP=`date '+%Y%m%d%H%M%S'`
EXIT_STATUS='SUCCESS'
BATCH_SOURCE=`echo ${DATA_DIR}/${BATCH_FILE}`
#################################################
# Converting the file #
#################################################
cat ${BATCH_SOURCE}|sed "s/$(printf "\243")//g">${BATCH_SOURCE}.new
mv ${BATCH_SOURCE}.new ${BATCH_SOURCE}
cat ${BATCH_SOURCE}|sed '/^\:61\:/s/ *//'>${BATCH_SOURCE}.new
mv ${BATCH_SOURCE}.new ${BATCH_SOURCE}
###############
## Final exit #
###############
 EXIT_STATUS='SUCCESS'
 echo "SEAS_CE_sh Status :" $EXIT_STATUS
 END_TIME=`date +%d-%b-%Y" "%H:%M`
 echo "Program Completed .... " $END_TIME
 echo "Moved ${BATCH_SOURCE}.new to ${BATCH_SOURCE}"
 exit 0
fi

#

1 comment:

  1. Regards,
    Harish
    Oracle technical and fusion cloud SCM online classes, if you are interested please whatsapp to this number +91 7382582893, thank you.

    ReplyDelete