2

I want to run foo if and only if the current day of the month is less than the 7th.

So something like:

[ (/bin/date +'%-d') -le 7 ] && foo

Except that gives me a syntax error. The date part is coming out right, so I'm asking for the right syntax for the conditional test.

1 Answer 1

3
[ $(/bin/date +'%-d') -le 7 ] && foo

The $() syntax will execute the statement within the parenthesis and return the result, which is what you want.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .