2

Say I have a output file with following:

010513  08:04   ROUTER1   192.168.1.1   68.130.5.10  HIT(1)
010513  08:04   ROUTER1   172.168.1.1   28.130.5.10  HIT(1)
010513  08:04   ROUTER1   122.168.1.1   168.130.5.10  HIT(1)
010513  08:04   ROUTER1   192.168.1.1   18.130.5.10  HIT(1)
010513  08:04   ROUTER1   152.168.1.1   58.130.5.10  HIT(1)
010513  08:04   ROUTER1   142.168.1.1   10.130.5.10  HIT(1)

I'm trying to sort with the 4th column followed by 5th and having highlighted colors would work too, as my true output file has about 20 columns. Tried using various grep | sort commands and having difficulty getting this to work without running my result file a few times. I don't script so I am sure there is one out there but thought I would ask if there are a combo command/variables I can try.

3

sort -V -k 4,5 could be what you're looking for. If you grep that output with say an IP pattern it would color the IPs (sort -V -k 4,5 < file | grep -E '([0-9]{1,3}\.){3}[0-9]{1,3}').

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.