1

I have tried a few other scripts that can make a static version of a wordpress site but none of them are designed for bulk sites and I haven't found any that will just serve a static version while keeping the original. Here was my attempt but now I'm getting a bash error line 10: syntax error near unexpected token ('

Here's my current code:

#!/bin/bash
for DOMAIN in "$@"
do
  cd /var/www/$DOMAIN/web/
  wget -m -r -p -N -F -E http://www.$DOMAIN
  mv www.$DOMAIN static-site
  mkdir _wordpress-site
  mv !(error|stats|_wordpress-site|static-site) _wordpress-site
  mv .htaccess _wordpress-site
  echo '
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ static-site/$1 [L]
</IfModule>
   ' > .htaccess
done

if I escape the line with a parentheses like: mv !\(error|stats|_wordpress-site|static-site\) _wordpress-site I get 3 command not found errors

I have also tried escaping like: mv '!(error|stats|_wordpress-site|static-site) _wordpress-site' which gives me mv: missing destination file operand after ‘!(error|stats|_wordpress-site|static-site) _wordpress-site’

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.