From 7bfda5959a346626dac3aa0959f2b4ae3232249b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Fri, 15 Jun 2018 16:30:20 +0200 Subject: Add function to generate random hex number --- shellrc.d/common | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/shellrc.d/common b/shellrc.d/common index 73707c5..7fc8047 100644 --- a/shellrc.d/common +++ b/shellrc.d/common @@ -47,6 +47,15 @@ genpasswd() { tr -dc A-Za-z0-9_ < /dev/urandom | head -c "$l" | xargs } +# Generate random hex number of given lenght +genhex() { + if [ -z "$1" ]; then + echo "Size is required as first argument!" >&2 + return 1 + fi + tr -dc 0-9A-F < /dev/urandom | head -c "$1" | xargs +} + # Automatic branch merger (merge branch, push it to server and remove branch) # Expects name of the branch as argument gitbmerge() { -- cgit v1.2.3