💾 Archived View for ait.place › roll.gmi captured on 2021-12-05 at 23:47:19. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-11-30)

-=-=-=-=-=-=-

Did you ever want just roll a simple dice in your terminal

There did not seem to be a shell script that simply rolled a couple of dice.

So I made a simple script that does it.

The syntax is as follows:

$ roll 2d20

This will roll two twenty sided dices

The output only gives the output of the rolls and nothing more.

#!/bin/sh

input=$*

[ -z "$input" ] && input=2d20

for request in $input ; do
	# check if format is correct
	echo $request| egrep -vq '^[0-9]+d[0-9]+


 && continue

	# Print and roll the dice
	shuf -r -i 1-$(echo $request|cut -dd -f2) -n $(echo $request|cut -dd -f1)
done