OpenNIC DNS updater script
This script will fetch a current list of DNS servers from api.opennicproject.org, filter them by countries if desired, sort by percentage, and write the result to files readable by various resolvers.
Shell Scripting For Speed
Inspired by a forum thread Choose which shell your scripts use, that's the "#/bin/*sh" at the top: dash: very small & fast but limited. you will have to use more external commands to accomplish things. bash: bulkier, takes longer to load, slightly slower (although to notice this at all one ha...
Pacman and Optional Dependencies
Archlinux packages list optional dependencies: "An array of packages that are not needed for the software to function, but provide additional features." But there's no special treatment built in for these packages, which can lead to problems (or at least needlessly left behind packages piling up). S...
Using GNU bash? Forget date!
Since Version 4.2.0 GNU bash can print times in strftime format with printf. OK, the external date command can do a lot that bash's builtin cannot do, but for most use cases this is enough - and it's always better to use builtins, because if you're using bloated bash, at least take full advantage of...
Load bash builtin from file
A few years ago I noticed that sleep is not built into bash and instead calls an external command each time. I like to make my scripts responsive and unobtrusive by relying on bash builtins as much as possible; my reasoning: I am using one of the heaviest shells with all its bells and whistles, so a...
Bash: Test if a string is a web link
I sometimes need this in my scripts: if a string starts with either http:// or https://, it must be a web link. How can I test for that in a single query? Like this: $ restore="$(shopt -p extglob)" $ regex="http?(s)://" $ shopt -s extglob $ x="http://wiki.archlinux.org/index.php" $ [[ "$x" == $regex...