mercredi 2 mars 2016

if statement based on string field

I have few strings which is "," separated. I need to search and replace the string based on the matched fields. For Eg.

Strings are:

MUMBAI,918889986665,POSTPAID,CRBT,CRBT,SYSTEM,151004,MONTHLY,160201,160302
MUMBAI,912398456781,POSTPAID,SEGP30,SEGP30,SMS,151004,MONTHLY,160201,160302

I need to write a script which will search and replaces the lines based on field number 4.

Illustration: (sudo code)

if [Field4==CRBT]

update line1 as:

 8889986665,ACT,DEFAULT,1,0,SYSTEM,2016-03-02 00:00:00

if [Field4==SEGP30]

update line2 as:

   2398456781,ACT,SEGP30_0,3,0,SMS,2015-03-02 00:00:00

After all the comparison, desired output should be:

 8889986665,ACT,DEFAULT,1,0,SYSTEM,2016-03-02 00:00:00
 2398456781,ACT,SEGP30_0,3,0,SMS,2015-03-02 00:00:00

Kindly help me with the shell script.

Aucun commentaire:

Enregistrer un commentaire