Tuesday, August 4, 2015

Script - sort data from a flat file

$ grep -i ilo /etc/hosts | \
> awk '{print $NF}' |\
> while read ips
> do
>     echo "https://$ips"
> done | sort -t. -n +3 -4
https://192.168.10.220
https://192.168.10.221
https://192.168.10.222
https://192.168.10.223
https://192.168.10.224


$ grep -i ilo /etc/hosts | more
192.168.10.120  server1 server1.exmp.local serv1 $ ILO 192.168.10.220
192.168.10.121  server2 server2.exmp.local serv2 $ ILO 192.168.10.221
192.168.10.122  server3 server3.exmp.local serv3 $ ILO 192.168.10.222
192.168.10.123  server4 server4.exmp.local serv4 $ ILO 192.168.10.223
192.168.10.124  server5 server5.exmp.local serv5 $ ILO 192.168.10.224

No comments:

Post a Comment