I'm trying to come up with something that will delete all text to end of line from a given character onwards.
E.g. in the example below I want to keep only the IP address:
192.168.2.121/32 -m comment --comment "blah blah bye bye" -j DROP
10.1.3.207 -m comment --comment "much longer comment with all kinds of stuff" -j DROP
172.16.1.0/24 -m comment --comment "Drop this range" -j DROP
The pattern to remove from is -m
, i.e., reading from left, the first "-" encountered. From that "-" to end-of-line should be deleted on every line in the file.
I'm stumped on this one, guidance would be appreciated.