arnpry
arnpry

Reputation: 1141

Insert Text Between Two Date Variables

I am trying to insert some text between two date commands

Code:

date -u "+%H":00Z --date="1 hours ago" "+%a %b %d" --date="0 days ago"

Error:

date: extra operand ‘+%a %b %d’
    Try 'date --help' for more information.

Expected Output:

11:00Z Fri Oct 20

Upvotes: 1

Views: 65

Answers (1)

RomanPerekhrest
RomanPerekhrest

Reputation: 92884

With GNU date , in 2 steps:

date -d @$(date +%s --date="0 days ago") -u "+%H:00Z %a %b %d"  --date="-1 hours ago"

Upvotes: 1

Related Questions