In Ubuntu 16.04, this is the code I have in /etc/cron.daily/cron_daily
:
#!/bin/bash
for dir in "/var/www/html/*/"; do
if pushd "$dir"; then
wp plugin update --all --allow-root
wp core update --allow-root
wp language core update --allow-root
wp theme update --all --allow-root
rse
popd
fi
done
I setted this up yesterday and today I got this error into my email:
/etc/cron.daily/cron_daily:
/etc/cron.daily/cron_daily: line 3: pushd: /var/www/html/*/: No such file or directory
Why is this happening? I assume the quote marks prevent the shell globbing but if so, what should replace them?
Bash
, indeed, as the answerers said, one cannot expand a shell glob / shell wildcard inside quote marks but one can do it with above-the-shell utilities likefind
.find
program does its own expansion in the latter case you mention. Whilefind
may imitate the shell's behavior, what is happening behind the scenes is different sincefind
is not the shell and calling whatfind
is doing a "shell glob" may be more confusing than helpful.