bash functions

Make a local variable and return the value as an echo. This overcomes global var names which can get very nasty in a large script.

function myfunc()
{
    local  myresult='some value'
    echo "$myresult"
}

result=$(myfunc)   # or result=`myfunc`
echo $result

Date-Time function

function dt_stamp()
{
   local myresult=$(date +%Y-%m-%d-%H-%M-%S)
   echo "$myresult"
}

ts_now=$(dt_stamp)

Randon ID Function

```bash function rnd_id() { local res=$(head -n 1 /dev/urandom | iconv -c -t 'utf-8' | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1) echo "$res" }