letakeda
letakeda

Reputation: 155

How do I transform linux date from 14-01-2015 to 14-1-2015?

How do I transform linux date from 14-01-2015 to 14-1-2015

I don't want that 0 in the %m

Here is the command I'm using:

DATE=$(date --date yesterday +%d-%m-%Y)

Thanks,

Upvotes: 2

Views: 58

Answers (1)

qqibrow
qqibrow

Reputation: 3022

try: date --date yesterday +%d-%-m-%Y

read the man page:

   By default, date pads numeric fields with zeroes.  The following optional flags may follow ‘%’:

   -      (hyphen) do not pad the field

   _      (underscore) pad with spaces

   0      (zero) pad with zeros

   ^      use upper case if possible

   #      use opposite case if possible

Upvotes: 5

Related Questions