< BACK
Bash tips, tricks and code snippets
Bash tip: Remove leading zeros from a variable
# Removes 1 or more longest occurrences from the beginning of the string
epoch="1593151200"
hour=`date +%H --date=@${epoch}` # "08"
hour=${hour##+(0)} # "8"
Refs
- http://tldp.org/LDP/abs/html/string-manipulation.html