It works fine in a command line,
 
but in a script, I get
 
#!/bin/bash
/usr/bin/rm -v !(GENBAS|fja.*|run.sh|test.sh|ZMAT*|out*)
 
./test.sh: line 2: syntax error near unexpected token `('
./test.sh: line 2: `/usr/bin/rm -v !(GENBAS|fja.*|run.sh|test.sh|ZMAT*|out*)'
 
 
[jwesterd@jwesterd-f33 aaa]$ ls -1
a
b
c
d
e
f
[jwesterd@jwesterd-f33 aaa]$ /usr/bin/rm   -v   !(a*|b*|c*|d*|e*)
removed 'f'
[jwesterd@jwesterd-f33 aaa]$ ls -1
a
b
c
d
e
[jwesterd@jwesterd-f33 aaa]$ echo $0
bash
 
seems to work?
 
Are there asterisks or quotes in the files you are affecting?
 
Cheers
 

John Westerdale 

Sr Container Consultant  RHCSA-8.2

Red Hat NYC Office/WFH 

john.westerdale@redhat.com   

M: 201-376-9993     IM: jwesterd   He / Him / His

I respect your Life-Work balance.

No need to respond immediately if you receive this outside your normal working hours.

 
On Fri, Jun 4, 2021 at 2:27 PM Patrick Dupre <pdupre@gmx.com> wrote:
Hello,

Sorry, I am a bit of list
This command line works in a shell, but not in a bash
I may miss some quotes !
Thanks for your help.

/usr/bin/rm -v !(ZMAT*|out*|Out*|GENBAS|Note*)

===========================================================================
 Patrick DUPRÉ                                 | | email: pdupre@gmx.com
 Laboratoire interdisciplinaire Carnot de Bourgogne
 9 Avenue Alain Savary, BP 47870, 21078 DIJON Cedex FRANCE
 Tel: +33 (0)380395988                    | | Room# D114A
===========================================================================
_______________________________________________
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-leave@lists.fedoraproject.org
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org
Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
_______________________________________________ users mailing list -- users@lists.fedoraproject.org To unsubscribe send an email to users-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure