Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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: stackoverflow.com/q/11685643/7552 –  glenn jackman Jul 27 '12 at 11:56
add comment

1 Answer

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
add comment

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.