1
0
Fork 0
mirror of https://github.com/kastdeur/dotfiles.git synced 2024-12-21 16:53:33 +01:00

[bin] added dotrev utility

This commit is contained in:
Eric Teunis de Boone 2021-01-07 15:58:53 +01:00
parent 0be4faaca0
commit 600f31775a

23
bin/dotrev Executable file
View file

@ -0,0 +1,23 @@
#!/bin/bash
# dotrev
# Reverse the order of substrings within a dotted string.
# Example: deboone.nl -> nl.deboone
while [ -n "$1" ]; do
tmp="$1"
REVHOSTNAME=""
while [ -n "$tmp" ]; do
piece="${tmp##*.}."
tmp="${tmp%.*}"
REVHOSTNAME="${REVHOSTNAME}${piece}"
if ! case "$tmp" in *.*) ;; *) false;; esac; then
REVHOSTNAME="${REVHOSTNAME}${tmp}"
unset tmp
unset piece
break;
fi
done
echo $REVHOSTNAME
shift
done