I'm trying to create a script which I can set as a cron job which adds all my dotfiles to a folder I've set up as a github repo then push them every evening. My script is the following.
cp ~/.!(|.|ssh|bash_logout|bash_history) ~/dotfiles git add . git commit -m "Test commit" git push origin master
I'm getting the following error:
./update_dotfiles.sh: line 3: syntax error near unexpected token `(' ./update_dotfiles.sh: line 3: `cp ~/.!(|.|ssh|bash_logout|bash_history) ~/dotfiles'
The command works perfectly when I run it it just errors when i'm running is as part of a shell script.The script is running bash,