From: Salve =?ISO-8859-15?Q?H=E5kedal?= on
This works well on the command line:

for f in !(*jpg); do echo $f; done

But in a script it gives this error message:
../script: line 1: syntax error near unexpected token `('
../script: line 1: `for f in !(*jpg); do echo $f; done'

Why?

(I use GNU bash, version 3.2.39(1)-release)

--
Salve
From: pk on
On Wed, 7 Jul 2010 17:49:06 +0000 (UTC)
salve(a)slogedalen.no (Salve Håkedal) wrote:

> This works well on the command line:
>
> for f in !(*jpg); do echo $f; done
>
> But in a script it gives this error message:
> ./script: line 1: syntax error near unexpected token `('
> ./script: line 1: `for f in !(*jpg); do echo $f; done'
>
> Why?
>
> (I use GNU bash, version 3.2.39(1)-release)

Put

shopt -s extglob

at the beginning of the script.

From: Salve =?ISO-8859-15?Q?H=E5kedal?= on
pk <pk(a)pk.invalid> wrote:
> On Wed, 7 Jul 2010 17:49:06 +0000 (UTC)
> salve(a)slogedalen.no (Salve H�kedal) wrote:
>
>> This works well on the command line:
>>
>> for f in !(*jpg); do echo $f; done
>>
>> But in a script it gives this error message:
>> ./script: line 1: syntax error near unexpected token `('
>> ./script: line 1: `for f in !(*jpg); do echo $f; done'
>>
>> Why?
>>
>> (I use GNU bash, version 3.2.39(1)-release)
>
> Put
>
> shopt -s extglob
>
> at the beginning of the script.
>
THANK YOU!

--
Salve