Search code examples
linuxbashsedcidr

delete CIDR with sed


How to delete lines containing CIDR notation with "sed" command?

Example file:

127.0.0.0/8
169.254.0.0/16
187.187.193.62
187.187.193.165
240.0.0.0/4

expected result sed ??? file > newfile:

187.187.193.62
187.187.193.165

Solution

  • Simple sed approach:

    sed -i '/\/[0-9]*$/d' file