Search code examples
pythonbashawkgrepcut

How do I can use "grep" on dynamically changing text?


so i've been wondering how can i get the variable x and y while using awk?

wall@bot:~$ geoiplookup 98.90.005.015
GeoIP Country Edition: USA, Alaska
GeoIP City Edition, Rev 1: UK, 12, Oakland, Wealth, 2155, XX.XXXX, YY.YYYY, 0, 0
GeoIP ASNum Edition: BS822828 McDonalds, America

Im appreciate any kind of help


Solution

  • s=$(geoiplookup 98.90.005.015 |awk -F', ' 'NR==2 {print $7,$8}')
    
    x=$(echo $s |awk '{print $1}')
    y=$(echo $s |awk '{print $2}')