* Per Jessen
Patrick Shanahan wrote:
* Per Jessen
[03-17-22 10:20]: Patrick Shanahan wrote:
I need to escape the periods in some ip addresses.
I need xc=111.111.111.111 to become 111\\.111\\.111\\.111
sed appears (or not) to be the proper utility but I cannot get the correct syntax.
In which context, Patrick? there are places where you need three backslashes, even four.
grep from bash control line grep 111\\.111\\.111\\.111
tks
Two options -
a) put the regex in quotes, then you need only one backslash. b) without qoutes, you need three backslashes.
I have presented, IP=${IP//./\\\\.} which works perfectly, but I didn't explain sufficiently to you my requirement. I need to grep $IP a file containing ip addresses and need to ensure the dots appear in the correct location as: grep 111.11.111.1 will match 111.1.1.1 without escaping the dot position this all but solves my need. I would also like to be able to drop the 4th quad and/or the 3rd and 4th. Is that also possible? I am trying to automagic blocking errant ip's using ipset and logs of sites trying to relay mail or gain unpermitted system access. I currently have a list of >10000 sites or ranges of sites blocked using above criteria. built over some years. and I realize that many are blocking ip4 sites that change address occasionally. ps: since some years ago moving ssh to a high port, I have a very low count of ssh attempts. -- (paka)Patrick Shanahan Plainfield, Indiana, USA @ptilopteri http://en.opensuse.org openSUSE Community Member facebook/ptilopteri Photos: http://wahoo.no-ip.org/piwigo paka @ IRCnet oftc What sort of day was it? A day like all days, filled with those events that alter and illuminate our times...