Let's imagine that on my server, i have the following files :
foo@bar:/var/log/foo$ ls
fooFile1 fooFile2 logFile logFile.1 logFile.2
I wanted to create an archive containing every file but logFile.*. So I came up with the command :
foo@bar:~$ tar -czf foo.tar.gz /var/log/foo/!(logFile.*)
And it works fine ! However, when trying to create a script which does the same job :
#!/bin/bash
tar -czf foo.tar.gz /var/log/foo/!(logFile.*)
I came across the following error :
./test.sh: line 3: syntax error near unexpected token '('
./test.sh: line 3: 'tar -czf foo.tar.gz /var/log/foo/!(logFile.*)'
The problem is not tar related (I met the same issue using ls instead of tar)
I don't understand where this error is coming from. Could anyone tell me where i am wrong ?
Met on Ubuntu 12.04