Comments (4)
Here's a sed command to remove duplicated '.' characters:
sed 's/\.\+/./g'
This is probably faster as it will only make the replacement if there are two or more '.' characters ...
sed 's/\.\.\+/./g'
from pi-hole.
The real challenge is to see if these can be combined into one, I'm not very good at simplification.
Here's a few more useful ones:
sed -e 's/ \.//g'
: remove periods at the start and the middle of domains.
sed -e 's/\[. ]+$/$/g'
remove domains ending in a period, and trailing white space.
from pi-hole.
Yeah, simplifying regexp statements to be optimized is rough. As long as I really don't require the speed I usually combine statements like this:
sed -e 's/\.\.\+/./g' -e 's/^[. ]*//' -e 's/\.* \+\.*/ /g' -e 's/[. ]\+$//'
This way it's easier for a human to look and see what's going on.
This removes duplicated .
characters and replaces with a single .
; removes spaces and .
characters at the front of the line; removes extra spaces and .
characters in the middle (leaving a single space); removes spaces and .
characters at the end of the line.
I tested it with the following example:
echo " .192.168.23.515.. ...foo...bar..com. " | sed -e 's/\.\.\+/./g' -e 's/^[. ]*//' -e 's/\.* \+\.*/ /g' -e 's/[. ]\+$//'
192.168.23.515 foo.bar.com
I also fixed our regexp examples in this post (we both had some errors). I had an extra /
at the end of my commands above (now editted); sed needs to have +
escaped, or it will try to match a +
character; $
in the second substitution section will put in an actual $
character; there was an extra \
before the [
, which would try to match a [
character instead of starting a list of possible characters to match. I also removed the g
from the end of the that can only match at the end of the line, since the global part isn't needed (doesn't break having it there though).
from pi-hole.
It looks pretty good, but it's a bit out of my skill level. Maybe someone could make a pull request and I can test it out.
from pi-hole.
Related Issues (20)
- Restore does not include static dhcp leases without ip HOT 3
- Temperature keeps reverting to Celsius from Fahrenheit when updating HOT 27
- Ads Not Blocking Properly in Pi-hole Docker HOT 6
- dnsmasq: failed to create listening socket for port 53: Address already in use HOT 4
- Blank admin PHP pages caused by empty persistentlogintoken file (includes fix) HOT 1
- Installation fails HOT 1
- Install: Check for valid upstream DNS IP addresses excludes IPv6 HOT 4
- (development-v6) cannot update FTL on arm device HOT 1
- (development-v6) cannot update FTL on amd64 device HOT 4
- Intermittent issues using custom dns_records HOT 2
- In an LXC container, the website displays a ‘load average’ that is very different from top HOT 7
- FTL database shouldn't be readable by unprivileged users HOT 6
- Raspberry Pi 5 having trouble binding interfaces when using NetworkManager HOT 1
- Update of pi-hole not possible on Linuxmint 6 (Debian) HOT 2
- pihole -v shows update available but pihole -up doesn't HOT 6
- Default list author fine with breaking functionality -- suggest finding alternative HOT 4
- Dashboard hanging HOT 1
- Consider NOT rate-limiting queries from the local router HOT 4
- Update (pihole -up) fails as installer (basic-install.sh) bypasses local DoH proxy HOT 3
- DHCP static reservation will not reset when changed. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pi-hole.