🌈 ☯️Teresita🐧👭 on Nostr: #Bash and #awk function to map decimal to Roman: #56 roman() { echo "$1" | awk '{ ...
#Bash and #awk function to map decimal to Roman: #56
roman() { echo "$1" | awk '{
x=$1
while(x>=1000){printf "M"; x-=1000}
if(x>=900){printf "CM"; x-=900}
if(x>=500){printf "D"; x-=500}
if(x>=400){printf "CD"; x-=400}
while(x>=100){printf "C"; x-=100}
if(x>=90){printf "XC"; x-=90}
if(x>=50){printf "L"; x-=50}
if(x>=40){printf "XL"; x-=40}
while(x>=10){printf "X"; x-=10}
if(x==9){printf "IX"; x-=9}
if(x>=5){printf "V"; x-=5}
if(x==4){printf "IV"; x-=4}
while(x>=1){printf "I"; x-=1}
printf "\n"
}';
}
Published at
2025-08-31 03:01:31 CESTEvent JSON
{
"id": "7c36c133a923e5a45522eafbe65754c754229b31f4a933a64bd54f1ee266564e",
"pubkey": "8c140c99f581f7c8bcd3fe169dc1fd070a849458c655f315db52daff293b25b9",
"created_at": 1756602091,
"kind": 1,
"tags": [
[
"t",
"bash"
],
[
"proxy",
"https://techhub.social/@linuxgal/115120674651428225",
"web"
],
[
"t",
"awk"
],
[
"imeta",
"url https://files.techhub.social/media_attachments/files/115/120/667/724/297/223/original/d1fba6f160b100d9.png",
"m image/png"
],
[
"proxy",
"https://techhub.social/users/linuxgal/statuses/115120674651428225",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://techhub.social/users/linuxgal/statuses/115120674651428225",
"pink.momostr"
],
[
"-"
]
],
"content": "#Bash and #awk function to map decimal to Roman: #56 \n\nroman() { echo \"$1\" | awk '{\n x=$1\n while(x\u003e=1000){printf \"M\"; x-=1000}\n if(x\u003e=900){printf \"CM\"; x-=900}\n if(x\u003e=500){printf \"D\"; x-=500}\n if(x\u003e=400){printf \"CD\"; x-=400}\n while(x\u003e=100){printf \"C\"; x-=100}\n if(x\u003e=90){printf \"XC\"; x-=90}\n if(x\u003e=50){printf \"L\"; x-=50}\n if(x\u003e=40){printf \"XL\"; x-=40}\n while(x\u003e=10){printf \"X\"; x-=10}\n if(x==9){printf \"IX\"; x-=9}\n if(x\u003e=5){printf \"V\"; x-=5}\n if(x==4){printf \"IV\"; x-=4}\n while(x\u003e=1){printf \"I\"; x-=1}\n printf \"\\n\"\n }'; \n}\nhttps://files.techhub.social/media_attachments/files/115/120/667/724/297/223/original/d1fba6f160b100d9.png\n",
"sig": "e61460fba501ebb3327fa9b7183bc52940e12bfc6364083b71b0078bd05de3574196b6f0d3e8f11f6b21e45610c25043d9de78807de20e6931f971178e38497f"
}