Skip to content

Instantly share code, notes, and snippets.

@meefs
Created October 15, 2024 17:37
Show Gist options
  • Select an option

  • Save meefs/849d2eecb3f58c64675873f90e74a7f2 to your computer and use it in GitHub Desktop.

Select an option

Save meefs/849d2eecb3f58c64675873f90e74a7f2 to your computer and use it in GitHub Desktop.
filename="blocked_$(date +%Y_%m_%d | sed 's/[0-9]\+/convert_to_roman &/g' | bash).log"
# Helper function (place this in your shell script or .bashrc)
convert_to_roman() {
number=$1
roman=""
declare -A numerals=(
[1000]=M [900]=CM [500]=D [400]=CD [100]=C [90]=XC
[50]=L [40]=XL [10]=X [9]=IX [5]=V [4]=IV [1]=I
)
for value in "${!numerals[@]}"; do
while (( number >= value )); do
roman+="${numerals[$value]}"
(( number -= value ))
done
done
echo -n "$roman"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment