Hi,
I have a requirement to split the file on different pattern and write to different files.
My scripts doing the work properly but i am facing a strange problem. while writing to different files the white space at the end of the each line is trimming.
That means if the original line in the file is 339 chars ; its trimming to 239 char in new file by trimming the white spaces in the end of the line ; which i dont want.
my scripts is as below:-
#!/usr/bin/ksh
#Mtv extract file directory
MTVFSDIR="D:/home/dsadm"
MTVFTPDIR="$MTVFSDIR/inbou
nd/mtv"
#Mtv extract log directory
MTVLOGSDIR="$MTVFSDIR/log"
#Mtv stag folder directory
MTVSTAGEDIR="$MTVFSDIR/sta
ge/mtv"
MTVLOG=$MTVLOGSDIR/$1".MTV
EXTRACT.LO
G."$CURRDA
TESTAMP
MTVARCH="$MTVFSDIR/archive
"
# Spliting of file start
echo "spliting start"
while read Line
do
match_char=`echo $Line | cut -c1-4`
echo $match_char
if test $match_char -eq 0001
then
echo "$Line" >> $MTVSTAGEDIR/stage_header.
txt
elif test $match_char -eq 0004
then
echo "$Line" >> $MTVSTAGEDIR/stage_bl_head
er.txt
elif test $match_char -eq 0010
then
echo "$Line" >> $MTVSTAGEDIR/stage_invoice
.txt
elif test $match_char -eq 0020
then
echo "$Line" >> $MTVSTAGEDIR/stage_contact
_detail.tx
t
elif test $match_char -eq 0030
then
echo "$Line" >> $MTVSTAGEDIR/stage_cash_de
tail.txt
elif test $match_char -eq 0040
then
echo "$Line" >> $MTVSTAGEDIR/stage_adj_det
ail.txt
elif test $match_char -eq 0050
then
echo "$Line" >> $MTVSTAGEDIR/stage_message
.txt
elif test $match_char -eq 0060
then
echo "$Line" >> $MTVSTAGEDIR/stage_corresp
.txt
elif test $match_char -eq 0070
then
echo "$Line" >> $MTVSTAGEDIR/stage_departm
ent.txt
elif test $match_char -eq 0080
then
echo "$Line" >> $MTVSTAGEDIR/stage_broker.
txt
elif test $match_char -eq 1000
then
echo "$Line" >> $MTVSTAGEDIR/stage_compone
nt.txt
elif test $match_char -eq 1100
then
echo "$Line" >> $MTVSTAGEDIR/stage_compone
nt_rider.t
xt
elif test $match_char -eq 1200
then
echo "$Line" >> $MTVSTAGEDIR/stage_contrac
t_summary.
txt
else
echo "$Line" >> $MTVSTAGEDIR/stage_reject.
txt
fi
done < $MTVFTPDIR/ABE.txt
echo "Spliting of file end"
STAMP=`date +%Y-%m-%d:%H-%M-%OS`
echo "Job Completed !!!..."
#everything goes well, exit with 0
Can any body help me out..
Thanks
deepak
Start Free Trial