Removing leading zeros from date output
As per the GNU date
manpage:
By default, date pads numeric fields with zeroes. The following
optional flags may follow '%':
- (hyphen) do not pad the field
Therefore you can do
alias date="date '+%Y.%-m.%-d.%-H.%-M.%-S'"
and receive
2013.6.14.3.19.31
Feels silly, but since this question is tagged with /sed
, here is a way to do this with sed, as you had mentioned :)
alias date='date +"%Y.%m.%d.%H.%M.%S" | sed "s/^0*//g; s/\.0*/./g"'