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.

slhck
  • 235,242
Hassen
  • 215

1 Answers1

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
  • 235,242