Sample Header Ad - 728x90

extract specific words and its data from html/xml file

0 votes
3 answers
247 views
sample input is output should be tid="8390500116294391399" ts="N/A" ets="2019-02-22T00:21:41.228Z" trxn="smaple data with spaces 2 record" trxn="smaple data with spaces 3rd record" trxn="smaple data with spaces 5th record" tid="2345500116294391399" ts="NA" ets="2017-02-22T00:21:41.228Z" trxn="other data with spaces" trxn="another record data" trxn="smaple data with spaces record" trxn="data with spaces" tid="2345500116294391399" ts="NA" ets="2017-02-22T00:21:41.228Z" I tried like below sed -e 's/trxn=/\ntrxn=/g' -e 's/tid=/\ntid=/g' -e 's/ts=/\nts=/g' while IFS= read -r var do if grep -Fxq "$trxn" temp2.txt then awk -F"=" '/tid/{print VAL=$i} /ts/{print VAL=$i} /ets/{print VAL=$i} /trxn/{print VAL=$i} /tid/{print VAL=$i;next}' temp2.txt >> out.txt else awk -F"=" '/tid/{print VAL=$i} /ts/{print VAL=$i} /ets/{print VAL=$i} /tid/{print VAL=$i;next}' temp2.txt >> out.txt fi done < "$input"
Asked by BNRINBOX (29 rep)
Apr 15, 2019, 04:45 AM
Last activity: Sep 19, 2019, 01:19 AM