i=1
while :
do
echo $i
x=$(cat file | grep '[0-9]\{1,3\}\.[0-9]\{1,3\}\.$i\{1,3\}\.[0-9]\{1,3\}')
echo $x
let i++
done
expected output, i want to sort ips in such a way first it will complete 192.168.1.1 to 192.168.1.254 then search 192.168.2.1 to 192.168.2.254 and so on go to 192.168.33.1 to 192.168.33.254.
What is your input data and which OS are you running? What you posted doesn't correspond with the input you posted earlier. The sort command doesn't change the data, only the order in which it's shown and your IP's seem to be missing some numbers.
I am using CENTOS Linux, There are hundered of ips, i just take few ips from order, but order is not correct as mentioned, if ips are not mentioned then no issue it will search for different subnet and make it order as mentioned above, if not present then discard that let it print the ips in order.
@learnbash
You have nearly 300 post here, you should now better than posting example that is not like your data, and expect us to solve it.
All the post above assume that IP is in column 1 and not 2 .
If you had posted some real data this would have been solved quick.