问题描述:

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
相关阅读:
Top