Created
October 15, 2024 17:37
-
-
Save meefs/849d2eecb3f58c64675873f90e74a7f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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