How can I assign a string to a variable like below:
Input content:
+++ USCDB 2016-07-29 20:19:53 PGW #036326 %%/*HWHandle=12547*/LST EPS:IMSI="515020211157018";%% RETCODE = 0 SUCCESS0001:Operation is successful
IMSI = 515020211157018
ISDN = 632000000016
EPS = NOTPROV
ANCHOR = FALSE
ICSIND = FALSE
Total count = 5
There is together 1 report
--- END
+++ USCDB 2016-07-29 20:19:53 PGW #036331 %%/*HWHandle=12547*/LST EPS:IMSI="515020211157020";%% RETCODE = 0
SUCCESS0001:Operation is successful
IMSI = 515020211157020
ISDN = 632000000018
EPS = PROV
AMBRMAXUL = 7104000
AMBRMAXDL = 15200000
RATFREQSELPRIID = 256
ANCHOR = FALSE
ICSIND = FALSE
MPS = FALSE
TAUTIMER = 0
MDT = NOTGIVEN
LTEAUTOPROV = FALSE
RELAY_NODE = FALSE
EPSODBPOS = NOBPOS
LTE_M2M_FLAG = FALSE
Total count = 15
There is together 1 report
While I'm currently using grep and awk to get the value above.
IMSI=$(echo $LINE | grep 'IMSI' | awk -F'=' '{print $2}')
ISDN=$(echo $LINE | grep 'ISDN' | awk -F'=' '{print $2}')
EPS=$(echo $LINE | grep 'EPS =' | awk -F'=' '{print $2}')
AMBRMAXUL=$(echo $LINE | grep 'AMBRMAXUL' | awk -F'=' '{print $2}')
AMBRMAXDL=$(echo $LINE | grep 'AMBRMAXDL' | awk -F'=' '{print $2}')
But when printing all IMSI value will be stored in one variable
Expected output:
515020211157018 632000000016 NOTPROV
515020211157020 632000000018 PROV 7104000 15200000
AMB RMAXULallowed?{}tool. If you think it is wrong, feel free to amend. Good luck to all.greptoawk.echo $LINE | grep 'IMSI' | awk -F'=' '{print $2}'is better writtenecho $LINE | awk -F= '/IMSI/{print $2}'ENDtag on the second report really missing in your input?