Hi,
I have a script that use some files and generate one file using these files. The main command that i am using in the script is the command cut, but it is very low, and i would like another command to generate my file faster...
My need is be able to use another command similar than "cut" but more fast...
thanks!!
Sorry for my english :o
the code is the next:
inputfile=LEGALENTITY.CSV
outputfile=EXIT.CSV
//these are some of the input files that i am using, but the content not
// is important
cfgfile1=CONTRASEC.csv
cfgfile2=TemplateCounterpartyFile.csv
cfgfile3=TEPR_Pcre_ListRecovery99.csv
cfgfile5=Pcre_ListDeveloped.csv
inputdir=$TEPR_DATIN
outputdir=/us/xatecees/Dani/IRC
#
# Cycle through all the Legal Entities in the file.
#
for lines in `cat $copyfile | sed "s/ /*/g"`;
do
cpy=`echo $lines | cut -f2 -d";"`
sector=`echo $lines | cut -f8 -d";"`
#
# Rating is preferably obtained from issuer rating file. If not possible,
# we use the Legal Entity rating.
#
rating=`grep "^$cpy " $TEPR_CFG_PAIS/TEPR_Pcre_Ratemi.txt | cut -f2 -d" "`
if [[ -z $rating ]]; then
rating=`echo $lines | cut -f9 -d";"`
fi
#
# Non rated counterparties now come as BB- in the Legal Entity file,
# so there is no more need to change CCCs. Old conversion is commented
# below.
#
# NLW Feb06
#
# Unknown ratings come as CCC. We transform them into BBB. Known CCC+
# and CCC- are transformed into CCC. Unfortunately, a known CCC will
# be considered BBB.
#
# if [[ $rating == "CCC" ]]; then
# rating="BB-"
# fi
if [[ $rating == "CCC+" ]]; then
rating="CCC"
fi
if [[ $rating == "CCC-" ]]; then
rating="CCC"
fi
if [[ $rating == "C" ]]; then
rating="CCC"
fi
# Rating information is now available in the the last field of the LEGAL_ENTITY file.
#
# Country information must be obtained from the HISTCLI and ALTACLI files that are
# in the dat/se directory. We generate cpylist as follows:
#
# `cat TEPR_TRIDA_In_????HISTCLI.TXT TEPR_TRIDA_In_????ALTACLI.TXT|cut -b2-11,97-99 | sort -u >cpylist`
# pais=`echo $cpyfile | cut -f2 -d" "`
# etc...
#
# If country is not found in cpyfile, we just set it to ES. Losses to the
# counterparty will be properly generated and included in the Spain group for
# marginal reports. An error message is issued
#
# We do not include any "group" counterparty, since there are no transactions
# related to them.
#
# NLW, Apr-2005
#
if [[ $cpy != G_* ]]; then
#
# We now obtain the country directly from the Legal Entity file, so there is
# no more need to use the cpylist methodology described above.
#
# Original code is commented below
#
# NLW Oct 05
#
# pais=`grep "^$cpy " $cfgfile4 | cut -b11-12`
pais=`echo $lines | cut -f10 -d";"`
if [[ -z $pais ]]; then
export TEPR_CodMsgCarga=TEPR5004S#INF00
export TEPR_MSG_ERRCOD=INFO
. $TEPR_UTI_MPAIS/TEPR_MPais_MsgScript.SH
pais="ES"
fi
#
# Obtain the recovery rate of the counterparty according to the contents of the
# TEPR_Pcre_ListRecovery99.csv (counterparties with 0.99 recovery) and to
# the sector field.
#
# Changed to include the list of developed countries that have 80% recovery for
# both the sector "Gobierno" and "Sector Financiero". However, the counterparties
# in the ListRecovery99 file still have 99% recovery, independent of country and
# sector. All the others have 60% recovery.
#
# NLW Oct 05
#
rr=0.60
banking=`grep \;$cpy\; $cfgfile3`
if [ $banking ]; then
rr=0.999
else
developed=`grep ^$pais $cfgfile5`
if [[ -n $developed ]]; then
if [[ $sector == "GOBIERNOS" ]]; then
rr=0.75
fi
fi
if [[ $sector == "SECTOR*FINANCIERO" ]]; then
rr=0.55
fi
fi
buffer=`grep ",$rating," $cfgfile2 | grep ",$rr,"`
buffer=`echo $buffer | sed "s/CONTRAPARTE/$cpy/g" | sed "s/PAIS/$pais/g" | sed "s/SECTOR/$sector/g" | sed "s/*/ /g"`
echo "cpy=$cpy pais=$pais sector=$sector rr=$rr"
echo "buffer: $buffer"
echo $buffer >>$outputdir/$outputfile
fi