hello all,
I need your help in extracting values of some parameter within a line using awk.
for example:
i have the below line available in a file and i want to extract the values of only CustomerId, s_PackageId and s_HZINumbers in order the result to be as
967666666666|"HomeZone"|"17103","10803","100000","200000","300000"
the file called test.file which has the contents as below:
Read:RPP(CustomerId="967666666666",OfferProfileKey=1,Key=7,category=ONLINE,prefetchFilter=-1,s_ActivationEndTime=32532613199999,s_ActivationStartTime=1459112400000,s_CRMTitle="-",s_CanBeSharedByMultipleRops=FALSE,s_InsertedViaBatch=TRUE,s_PackageId="HomeZone",s_PeriodStartPoint=0,vValidFrom=2016-03-28 00:00:00,vInvalidFrom=4000-01-01 00:00:00,s_FreeOfChargeModifyTasks=0,s_HZINumbers=["17103","10803","100000","200000","300000"],s_PeriodicBonus={CreditLimit=0,CreditMax=1000000},s_Touched=TRUE,bCategory=ONLINE,bSeriesId=0,bValidFrom=2009-01-01 00:00:00,bInvalidFrom=MAX_DATEANDTIME,s_Active=TRUE,s_ExpireDate=3000-01-01,s_FreeOfChargePeriods=0,s_NextPeriodAct=32532613199999,s_OnTouchDate=32532613199999,s_StartDate=1970-01-01,s_Valid=TRUE);
i used the below command
awk '{if (!match($0, /CustomerId=([-0-9a-zA-Z]*)/)) next; cust = (substr($0, RSTART + 12, RLENGTH + 1));if (!match($0, /s_PackageId="HomeZone"/)) next; pkg = (substr($0, RSTART + 12, RLENGTH -12));if (!match($0, /s_HZINumbers=([-0-9a-zA-Z,]*)/)) next; hzin = (substr($0, RSTART + 14, RLENGTH - 14));printf("%s|%s|%s\n", cust,pkg,hzin); }' test.file
i get the result for customerid, and package only. the result for s_HZINumbers is not appearing.
967666666666|"HomeZone"|
i would appreciate it if you get it solved for me,
Thank you