+ 2

Problem command system Linux

I have problem in command is not working correctly I want to sort third field and fourth field using command $ sort -t. -k3n -k4n sort delimiter is point '.' -n, --numeric-sort : compare according to string numerical value. $ nano sort $ cat sort 192.168.1.245.www.test.com.80 192.168.1.17.www.test.net.8012 192.168.2.5.www.test.org.8001 192.168.3.1.www.test.ma.8098 192.168.2.15.www.test.to.8080 $ sort -t. -k3n -k4n sort 192.168.1.17.www.test.net.8012 192.168.1.245.www.test.com.80 192.168.2.15.www.test.to.8080 192.168.2.5.www.test.org.8001 192.168.3.1.www.test.ma.8098 It has to be like this because 5 < 15 192.168.1.17.www.test.net.8012 192.168.1.245.www.test.com.80 192.168.2.5.www.test.org.8001 192.168.2.15.www.test.to.8080 192.168.3.1.www.test.ma.8098

20th Apr 2022, 12:49 PM
HICHAM
3 Réponses
+ 7
You have to specify where the sort keys start AND end. sort -t. -k3,3n -k4,4n sort
20th Apr 2022, 1:43 PM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 3
Wlcm
20th Apr 2022, 1:54 PM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 2
Thx
20th Apr 2022, 1:53 PM
HICHAM