-
1
- #1
I have script to read a file, reformat the record and output to second file. the output file has a date in julian format (YYDDD) for which i am currently using the system date. I need to be able to read the date in the orginal file and convert this. Here's my script :-
#!/bin/ksh
#
#
jul=`date +%y%j`
{ while read myline;do
# echo $myline
TY=`expr substr "$myline" 1 1`
AC=`expr substr "$myline" 325 8`
SC=`expr substr "$myline" 314 6`
CAC=`expr substr "$myline" 58 6`
CSC=`expr substr "$myline" 69 8`
CN=`expr substr "$myline" 103 18`
REF=`expr substr "$myline" 600 18`
AM=`expr substr "$myline" 44 14`
EN=`expr substr "$myline" 359 18`
DT=`expr substr "$myline" 1100 8` # Date stored in YYYYMMDD format
F1='099'
F2='0'
f3=' '
if [ $TY = 'B' ]
then
echo $DJ
echo $DT
echo "$SC""$AC""$F1""$CSC""$CAC""$F2""$AM""$CN""$REF""$EN"' '"$jul" >> /home/huntb/fsp1.txt
fi
done } < /home/huntb/fsp.txt
Any help would be much appreciated
Sorry if this has been asked before, have found similar threads but nothing i could use.
#!/bin/ksh
#
#
jul=`date +%y%j`
{ while read myline;do
# echo $myline
TY=`expr substr "$myline" 1 1`
AC=`expr substr "$myline" 325 8`
SC=`expr substr "$myline" 314 6`
CAC=`expr substr "$myline" 58 6`
CSC=`expr substr "$myline" 69 8`
CN=`expr substr "$myline" 103 18`
REF=`expr substr "$myline" 600 18`
AM=`expr substr "$myline" 44 14`
EN=`expr substr "$myline" 359 18`
DT=`expr substr "$myline" 1100 8` # Date stored in YYYYMMDD format
F1='099'
F2='0'
f3=' '
if [ $TY = 'B' ]
then
echo $DJ
echo $DT
echo "$SC""$AC""$F1""$CSC""$CAC""$F2""$AM""$CN""$REF""$EN"' '"$jul" >> /home/huntb/fsp1.txt
fi
done } < /home/huntb/fsp.txt
Any help would be much appreciated
Sorry if this has been asked before, have found similar threads but nothing i could use.