Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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

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

share|improve this answer
    
Thanks a lot! I missed the $. –  Sean Mar 26 '12 at 15:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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