Hi Experts
I need your help to optimize my script to execute better as I have nearly 1M records & the script is taking close to 40 minutes to execute, so would need support on a faster alternative.
Input: file
{"house":"1024","zip":"2345","city":"asd","country":"zzv"}
{"city":"asd","house":"1024","zip":"2845","country":"zzv"}
{"house":"1028","zip":"2645","city":"asd","country":"zzv"}
{"zip":"2545","house":"1021","city":"asd","country":"zzv"}
{"city":"asd","house":"1020","zip":"2345","country":"zzv"}
Script:
for i in `cat file`
do
HNO=`echo $i | awk -F"\"house\":" '{print $2}'| cut -d"," -f1 | sed 's/\"//g'`
ZIP=`echo $i | awk -F"\"zip\":" '{print $2}'| cut -d"," -f1 | sed 's/\"//g'`
CIT=`echo $i | awk -F"\"city\":" '{print $2}'| cut -d"," -f1 | sed 's/\"//g'`
echo 'House number is '$HNO', Zip Code is '$ZIP', City is '$CIT' and Country is zzv'
done
Output:
House number is 1024, Zip Code is 2345, City is asd and Country is zzv
House number is 1024, Zip Code is 2845, City is asd and Country is zzv
House number is 1028, Zip Code is 2645, City is asd and Country is zzv
House number is 1021, Zip Code is 2545, City is asd and Country is zzv
House number is 1020, Zip Code is 2345, City is asd and Country is zzv
Thanks for your help in advance
Regards
Nk