Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

shell prog question

  • 11-05-2003 01:57PM
    #1
    Closed Accounts Posts: 85 ✭✭


    Hi,
    I'm trying to get the date command to work int he following format:
    date -d '1970-01-01 56700 seconds'

    but when I try to insert a command line argument instead of 56700 I run into problems...I've tried everything that I can possibly think of and heres my latest attempt:

    temp="'1970-01-01 $1 seconds'"
    dateStatement="date -d ${temp}"
    dateresult=`${dateStatement}`

    And the result:
    date: too many non-option arguments: seconds'
    Try `date --help' for more information.

    If anyone could help I'd be eternally greatful...'cos knowing my luck it'll appear in my end of year exam tomorrow!

    Thanks.
    :)


Comments

  • Moderators, Social & Fun Moderators Posts: 10,501 Mod ✭✭✭✭ecksor


    I think you want

    dateStatement="date -d '${temp}'"

    So the single quotes get passed to the final command in the backquotes.


Advertisement