当前位置: 动力学知识库 > 问答 > 编程问答 >

uniq - Unix: unique based on first 24 bytes of IP

问题描述:

I have a file that has the following IP's:

64.5.12.3

64.5.12.8

122.4.5.1

122.4.5.6

How to unique based on only the first 24 bytes such that, the output is:

64.5.12

122.4.5

网友答案:

Use cut and sort:

cut -c-7 inputfile | sort -u

For your input, it'd produce:

122.4.5
64.5.12

If I understand it correct, you might want to use the following:

cut -d. -f-3 inputfile | sort -u
分享给朋友:
您可能感兴趣的文章:
随机阅读: