String manipulation

Hi All,

Pls help me out on the below,

          05  LAMSZ201-ZM-MEMO2-DATE02-5    PIC X(10).
           05  LAMSZ201-ZM-MEMO2-AMT02-5     PIC S9(13)V99.
           05  LAMSZ201-ZM-MEMO2-TYPE02-6    PIC XXX.
           05  LAMSZ201-ZM-MEMO2-DATE02-6    PIC X(10).
           05  LAMSZ201-ZM-MEMO2-AMT02-6     PIC S9(13)V99.
           05  LAMSZ201-ZM-MEMO2-TYPE02-7    PIC XXX.
           05  LAMSZ201-ZM-MEMO2-DATE02-7    PIC X(10).
           05  LAMSZ201-ZM-MEMO2-AMT02-7     PIC S9(13)V99.

with the above input. i need to take 2 and 4 column also i need to replace the 4th column eg. S9(13)V99 as decimal 16 and X(10) has Varchar 10

i tried these things..

grep PIC DWAFHI01.cpy | awk '{ print $2,$4,$5}' >tempcopyfile.txt
awk '/S9/ { sub(/Integer/,"S9"); print} ' tempcopyfile.txt > newfile

since i am new to unix scripting i am unable to proceed further. please help me on this

Thanks in advance..

Baski

Try this.

 awk '{printf "%s ", $2; if($4=="X(10)."){printf "Varchar 10\n"}else if($4=="S9(13)V99."){printf "decimal 16\n"}else{print $4}}' test.txt

Thanks a lot !!!!!!!

let me try ...