-2

From https://stackoverflow.com/a/27595805/156458

date -d "next ${1- hour}" '+%H:00:00'

What is ${1- hour}? Is it some shell parameter expansion, or input format of date and time?

Why does ${1 hour} not work?

Thanks.

Tim
  • 101,790

1 Answers1

3

It's a parameter expansion, expanding to the text hour if the first positional parameter is unset. Had the expansion been ${1:- hour}, then it would have expanded to hour also if the first positional parameter was empty (but set).

The code in the StackOverflow answer that you are linking to expects the first positional parameter to be something like day or week, but defaults to hour using this expansion if the argument is not provided.

Kusalananda
  • 333,661