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.

So if cwd is the /tmp now:

crontab -l
> #min hour day mon dow  command
> * * * * * /usr/local/bin/growlnotify -t 'helloTitle' -m 'helloMessage' -n 'myApp' -sw

but:

echo $(crontab -l)
> #min hour day mon dow  command 0004d519be91d 0004d519d798b launch-0NKnNe launch-NdhkpV
launch-bqJRD2 launch-zac20v launchd-276.rbWQ6r 0004d519be91d 0004d519d798b launch-0NKnNe
launch-NdhkpV launch-bqJRD2 launch-zac20v launchd-276.rbWQ6r 0004d519be91d 0004d519d798
launch-0NKnNe launch-NdhkpV launch-bqJRD2 launch-zac20v launchd-276.rbWQ6r 0004d519be91d 
0004d519d798b launch-0NKnNe launch-NdhkpV launch-bqJRD2 launch-zac20v launchd-276.rbWQ6r 
0004d519be91d 0004d519d798b launch-0NKnNe launch-NdhkpV launch-bqJRD2 launch-zac20v 
launchd-276.rbWQ6r /usr/local/bin/growlnotify -t 'helloTitle' -m 'helloMessage' -n 'myApp' -sw

so first line + /tmp content + last line of the crontab

Why such a behavior? I need the $(crontab -l) for if [[ $(crontab -l | grep "^...$") =~ "^...$"]]

share|improve this question
add comment

1 Answer

You get the file list because “crontab -l” returns star characters (*) that get then interpreted as glob characters.

I suggest you use 'set -f' in your shell script around your test to turn of glob interpretation:

set -f
if $(crontab -l | grep -q "^...$"); then
  # your stuff
fi
set +f
share|improve this answer
    
I knew it! Thank you very much for the set -f! –  static May 20 '13 at 13:44
5  
one could make also echo "$(crontab -l)", helps too –  static May 20 '13 at 13:46
2  
Double-quotes is a much better way to solve this. –  Gordon Davisson May 20 '13 at 16:01
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.