How can I get a line break in the "date" command on OS X?

1

Is it possible to force a line break in the result of date command for Mac OS X?

This is intended to use with GeekTool so I can have the current date in the first line, and time in the second.

For now, I'm using two separate commands. The first one for date:

date '+%A %B %d, %Y'

And the second for time:

date '+%l:%M %p'

I tried to insert \n and CR, but without success.

htaidirt

Posted 2013-07-28T11:10:07.400

Reputation: 185

Answers

4

You can't use \n, but %n works – see man strftime.

date '+%A %B %d, %Y%n%l:%M %p'

Will output:

Sunday July 28, 2013
 2:18 PM

(Note that the initial whitespace on the second line is caused by the padded format.)

slhck

Posted 2013-07-28T11:10:07.400

Reputation: 182 472

Great! Thanks a lot slhck for the answer and the reference. – htaidirt – 2013-07-28T13:02:53.600