Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using $date command in a Unix script and it is giving as "Tue Aug 27 05:53:37 EDT 2013".

This is coming as an automatic mail.

The timestamp value is long and it wraps to new line.

How can I adjust command such that time format does not wrap into new line?

share|improve this question
add comment

2 Answers

This should do the trick:

#!/bin/bash
DATE=`date +%Y-%m-%d`

If you do man date, you will find all possible placeholders to construct your date string.

share|improve this answer
add comment

man date shows all possible output options, you coud for example use

$ date +%D
09/11/13
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.