Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to call a variable in the below manner? in this case X=$(date --date=yesterday +%Y-%m-%d)

echo $X --> 2012-07-26

The below command works but even if the date is in 25 it considers. Means $X is considered as null and picks *. Is there a way specifically call that variable in below place $X.?

find . -maxdepth 1 -type f -regex '.(/\asyncprocessor.log.'$X'\|/Renewal.log.'$X'\|/Scheduler.log.'$X'\|/smsprocessor.log.'$X'\|/Subscription.log.'$X').*' -exec ls -ltr {} \;

share|improve this question
Also asked on stackoverflow: – glenn jackman Jul 27 '12 at 11:56

find . -maxdepth 1 -type f -regex './(asyncprocessor\|Renewal\|Scheduler\|smsprocessor\|Subscription).log.'$X'.*' -exec ls -ltr {} \;

Works in the above way ;)

share|improve this answer

Your Answer


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.