Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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 dont 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.

share|improve this question
add comment

1 Answer

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}').

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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