tag 13517 notabug thanks On 01/20/2013 11:59 PM, Vinay Jain wrote: > Hi, > > I want to change the date format in linux. How can i do it? > > Right now if i will fire a command: date '+%D' then it will display 01/20/13. > I want that when i fire the command date '+%D' then it should be displayed > as 20/01/2013. > > How can i achieve this?
You probably want to use %x (locale-specific date representation) instead of %D (hard-coded to %m/%d/%y), and then be sure that your environment contains an appropriate LC_ALL to pick up locale rules where %x expands to your desired format. Another option (but less flexible) is to call out the pieces instead of using the meta symbol (that is, use +%d/%m/%Y instead of %D). As this is a usage question, and not a bug, I've gone ahead and closed it so the tracker doesn't report something that still needs fixing in coreutils code. However, you should feel free to reply with any further comments or questions on the issue. Also, while your particular question didn't touch on any of the FAQ, you might find it helpful to read this, covering other subtleties and common questions about date: https://www.gnu.org/software/coreutils/faq/coreutils-faq.html#The-date-command-is-not-working-right_002e -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature