Simple 'printf' question

Discussion in 'Programming/Scripts' started by autogun, Feb 8, 2010.

  1. autogun

    autogun New Member

    Howdy,

    I'd like to use 'printf' with '/bin/date' function on my Linux server.
    For example: 'printf Today is /bin/date'
    Result: Today is Mon Feb 8 23:57:43 IST 2010

    What is the right way to put it?

    Thanks in advance!
     
  2. acomputerwiz

    acomputerwiz New Member

    Code:
    printf "Today is `date`\n"
    Note that around the "date" is a tilde ` not a single quote

    \n is newline
    \r is return

    Enclosed in tilde's you can put any commands you want. For example:

    Code:
    printf "Today is `date +%M%D%Y`\n"
    if you only want certain parts of the date.
     
  3. autogun

    autogun New Member

    Thanks a bunch, acomputerwiz!
     

Share This Page