1751817 Members
5502 Online
108781 Solutions
New Discussion

Re: field format

 
SOLVED
Go to solution
PING_6
Esteemed Contributor

Re: field format

tl=5
for j in `cat /tmp/inp_file`
do
i=1
while [ $i -le $tl ]
do
case $i in
1 ) f1=`echo $j | cut -c 3- | cut -f 1 -d ","` ;;
2 ) f2=`echo $j | cut -c 3- | cut -f 2 -d ","`
y=`echo $f2 | cut -c -4`
m=`echo $f2 | cut -c 5-6`
d=`echo $f2 | cut -c 7-`
f2=`echo $y-$m-$d`
;;
3 ) f3=`echo $j | cut -c 3- | cut -f 3 -d ","`
y=`echo $f3 | cut -c -4`
m=`echo $f3 | cut -c 5-6`
d=`echo $f3 | cut -c 7-`
f3=`echo $y-$m-$d`
;;
4 ) f4=`echo $j | cut -c 3- | cut -f 4 -d ","`
fs=`echo $f4 | cut -c -2`
ss=`echo $f4 | cut -c 3-`
f4=`echo $fs:$ss`
;;
5 ) f5=`echo $j | cut -c 3- | cut -f 5 -d ","`
fs=`echo $f5 | cut -c -2`
ss=`echo $f5 | cut -c 3-`
f5=`echo $fs:$ss`
;;
esac
i=`expr $i + 1`
done
echo "$f1 $f2 $f3 $f4 $f5"
done


HTH
Whatever exists is changeable and what is not changeable does not exist.