-1

So i need a bash script to sort this list

103.145.72.0/24  Alibaba.com HK(Kaopuyun)   256
110.76.21.0/24   Zhejiang Ant Small And Micro Financial Services    256
122.254.76.0/23  Internet Global (group) Co., LTD   512
116.251.120.0/22     Zhejiang Taobao Network Co.,Ltd    1,024
149.129.16.0/23  Alibaba.com Singapore E-Commerce Private Limited   512
8.209.96.0/19    Westendstrabe 28, 60325 Frankfurt am Main  8,192

In

103.145
110.76
122.254
116.251
149.129
8.209

Can someone help me? I tried something but it didn't work out as I expected

oguz ismail
  • 1
  • 16
  • 47
  • 69
Maz4id
  • 15
  • 2
  • 1
    Show what you've tried – oguz ismail Apr 27 '20 at 09:45
  • 1
    Have a look at the sort command.`man sort` to the rescue (`sort -t. -k1n,2n`) – kvantour Apr 27 '20 at 09:48
  • Does this answer your question? [sort by column linux](https://stackoverflow.com/questions/18309538/sort-by-column-linux). You may take also advantage from [Sorting data based on second column of a file](https://stackoverflow.com/questions/6438896/). – U880D Apr 27 '20 at 10:46

1 Answers1

0

You can try regex pattern to match what you need with grep. Here is example regex I tried: https://regex101.com/r/aBDlyf/1

On terminal you can try something like this:

grep -Eo "^[0-9]{1,3}.[0-9]{1,3}" filename.txt
kadir
  • 589
  • 1
  • 7
  • 29