2

Code

shopt -s extglob
cp -r !(Backups.backupdb) /home/masi/Documents/
cp -r !(Applications.noindex) /home/masi/Documents/

where note that you cannot use forward-flash in the glob environment although TAB-completion gives it to you, as described in the thread Why extglob except breaking except condition?

How can you combine the two NOT clauses in extglob?

Community
  • 1
  • 1
Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697

1 Answers1

4

Assuming you mean "everything except one of the two patterns", you just combine them with a |:

cp -r !(Backups.backupdb|Applications.noindex) /home/masi/Documents/
Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697
rici
  • 234,347
  • 28
  • 237
  • 341
  • Sorry, I had to correct my mistake which was carried forward to your answer. It is wrong to use forward-flash in the glob environment. One thread about it here http://stackoverflow.com/questions/31596677/why-extglob-except-breaking-except-condition – Léo Léopold Hertz 준영 Jul 27 '15 at 10:18