0

I have test case which contains string message in double quotes and I want to strip off data in double quotes. I used awk command to strip off comment section data but it doesn't work

awk '/^"/ { print }' full-case

sample input:

case('pr_ua_sfochi', "Response:answer(amount(2370.09,usd)", price).

Expected output:

case('pr_ua_sfochi',price).

Please advice.

awk '{gsub(/".*",/,"");print}' file.txt is working for above case but failed for following case.Here 2nd argument is in double quotes.

Actual case:

case('pr_ua_sfochi',"
Response:

answer(amount(2370.09,usd),[[01AUG06SFO UA CHI Q9.30 1085.58FUA2SFS UA SFO Q9.30 1085.58FUA2SFS NUC2189.76END ROE1.0 XT USD 180.33 ZPSFOCHI                                                           164.23US6.60ZP5.00AY XF4.50SFO4.5]],amount(2189.76,usd),amount(2189.76,usd),amount(180.33,usd),[[fua2sfs,fua2sfs]],amount(6.6,usd),amount(                                                          4.5,usd),amount(0.0,usd),amount(18.6,usd),lasttktdate([20061002]),lastdateafterres(200712282]),[[fic_ticketinfo(fare(fua2sfs),fic([]),nvb([                                                          ]),nva([]),tktiss([]),penalty([]),tktendorsement([]),tourinfo([]),infomsgs([])),fic_ticketinfo(fare(fua2sfs),fic([]),nvb([]),nva([]),tktiss                                                          ([]),penalty([]),tktendorsement([]),tourinfo([]),infomsgs([]))]],<>,<>,cat35(cat35info([])))
.
02/20/2006 17:05:10 Transaction 35 served by static.static.server1 (usclsefat002:7551) running E*Fare version $Name: build-2006-02-19-1900                                                           $",
price(pnr(
        user('atl','1y',<>,<>,dept(<>,'0005300'),<>,<>,<>),
        [
                passenger(adt,1,[ptconly(n)])
        ],
        [

segment(1,sfo,chi,'ua','<>','100',20140901,0800,f,20140901,2100,'737',res(20140628,1316),hk,pf2(n,[],[],n),<>,flags(no,no,no,no,no,no,no,no                                                          ,no)),

segment(2,chi,sfo,'ua','<>','101',20140906,1000,f,20140906,1400,'737',res(20140628,1316),hk,pf2(n,[],[],n),<>,flags(no,no,no,no,no,no,no,no                                                          ,no))
        ]),[
                rebook(n),
                ticket(20140301,131659),
                dbaccess(20140301,131659),
                platingcarrier('ua'),
                tax_exempt([]),
                trapparm("trap:ffil"),
                city(y)
        ])).
5
  • is the quoted string always in the second field?
    – cas
    Jun 23, 2016 at 2:01
  • No.It may vary commented section. Jun 23, 2016 at 8:08
  • 1
    Apparently the string can contain an arbitrary number of newlines, a fact you did not consider important enought to mention right away... Jun 23, 2016 at 8:51
  • Also, what about trapparm("trap:ffil")? Strip or keep? Jun 23, 2016 at 13:56
  • We need to keep that. Jun 23, 2016 at 14:25

1 Answer 1

2

You can accomplish this with awk

awk '{sub(/".*",/,"");print}' filename
4
  • I think he is looking to remove text within quotes, including quotes and a comma following the quotes
    – Sundeep
    Jun 22, 2016 at 13:45
  • Updated to also remove the trailing comma. Jun 22, 2016 at 13:48
  • You use gsub, which implies you expect several double quoted strings. But then your regex is too greedy. Jun 22, 2016 at 14:25
  • I updated the answer and sub'd gsub for sub. Thank you for pointing that out. I'm just used to using gsub all the time (a bad habit of mine) Jun 22, 2016 at 14:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .