Is there a way in BASH to convert an integer to a shortened alphanumeric string?
If I start, let's say with var=20171019194210
. I would like to get something like the following.
echo "$var" | encoding
a4f5e6g
And then:
echo "$var" | decoding
20171019194210
I found something in Python on Stackoverflow; but, if possible, I would prefer to use BASH with any combination of GNU tools like awk
to do it.
I am trying to create a unique ID for files by creating a timestamp as follows.
date +"%Y%m%d%H%M%S"
I then include this timestamp in the file name to identify the file on the system without needing to use a whole filename or to be able to identify the file without the rest of the file name.
I would now like to shorten or encode this integer to make it more usable in terms of its length, but in the same way having the possibility to recalculate the timestamp value.