Skip to main content
added 84 characters in body
Source Link
RudiC
  • 9.1k
  • 2
  • 12
  • 22

Are there other fields that could hold your pattern (the sample doesn't have any)? If not, try

grep -Eo "([0-9]{1,3}\.){3}[0-9]{1,3}" file | sort -u
11.01.196.0
13.13.173.59
141.101.196.40
14.19.232.42
19.13.13.159
6.5.8.12
66.55.89.12

If you want it sorted numerically, use sort's -g option.

For your own solution given in the question, try -f2,5 for the cut fields.

Are there other fields that could hold your pattern (the sample doesn't have any)? If not, try

grep -Eo "([0-9]{1,3}\.){3}[0-9]{1,3}" file | sort -u
11.01.196.0
13.13.173.59
141.101.196.40
14.19.232.42
19.13.13.159
6.5.8.12
66.55.89.12

If you want it sorted numerically, use sort's -g option.

Are there other fields that could hold your pattern (the sample doesn't have any)? If not, try

grep -Eo "([0-9]{1,3}\.){3}[0-9]{1,3}" file | sort -u
11.01.196.0
13.13.173.59
141.101.196.40
14.19.232.42
19.13.13.159
6.5.8.12
66.55.89.12

If you want it sorted numerically, use sort's -g option.

For your own solution given in the question, try -f2,5 for the cut fields.

Source Link
RudiC
  • 9.1k
  • 2
  • 12
  • 22

Are there other fields that could hold your pattern (the sample doesn't have any)? If not, try

grep -Eo "([0-9]{1,3}\.){3}[0-9]{1,3}" file | sort -u
11.01.196.0
13.13.173.59
141.101.196.40
14.19.232.42
19.13.13.159
6.5.8.12
66.55.89.12

If you want it sorted numerically, use sort's -g option.