-3

This question already has an answer here:

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.

marked as duplicate by Ipor Sircer, αғsнιη, LinuxSecurityFreak, schily, Jesse_b Jul 29 '18 at 14:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.