I can not use sed in this case because sed look for a file, but I look for a field.
here is my code:
========
#!/bin/ksh
cd /DATA
for file in MainCD*log; do
newFile=`ls -1 $file|awk -F. '{ \
y = substr($1,7,4); \
m = substr($1,11,2); \
d = substr($1,13,2); \
printf "irv-%s%s%s.dat",y,m,d \
}'`
grep "," $file |
sort -t"|" +1 -2 +5 -6 |
awk -F"," '{
if (($5 == "002") && ($6 == "FE")) {
ani = $7;
logdate = $3;
logtime = $4;
lastloc = $10;
acc = $9;
if ($19 !~ /^FE|^MN/)
sub(/^:/,"",firstloc)
printf "%s|%s|%s|%s|%s|%s\n",ani,logdate,logtime,firstloc,lastloc,acc;
}
}' |
sort -t, +0 -1 > /NEWDIRECT/$newFile
done
============
I really want the firstloc have only
firstloc=SV-SvcMenu
or
firstloc= BP-FinStatus
Please show me what trick you will use
Thanks,