3

Error

line 852: syntax error near unexpected token `('

Line 852 is the last line of a function:

touch --reference="$KERNEL_FILE" "$moduledest"/modules.(*.bin|devname|softdep)

No error

When inserting the exclamation mark ! before (:

touch --reference="$KERNEL_FILE" "$moduledest"/modules.!(*.bin|devname|softdep)

How to touch the inverse of !(*.bin|devname|softdep)?

/modules.alias.bin
/modules.builtin.bin
/modules.dep.bin
/modules.devname
/modules.softdep
/modules.symbols.bin
telis80
  • 92
  • 1
  • 12
Pro Backup
  • 729
  • 14
  • 34
  • I could have sworn we had duplicates to this in the knowledgebase -- but while we have [How can I use inverse or negative wildcards when matching a pattern in UNIX/Linux?](https://stackoverflow.com/questions/216995/how-can-i-use-inverse-or-negative-wildcards-when-pattern-matching-in-a-unix-linu/217017) and several dupes thereto, I'm not finding an exact match that comes from the perspective of asking why the syntax is valid. – Charles Duffy Dec 10 '17 at 19:20
  • On the other hand, if your real question wasn't about the error but was "what is the inverse to [a negative extglob]"?, then that's a bit easier to find duplicative questions for (one doesn't need to use a positive extglob for the purpose -- one can also enable `nullglob` and just refer to multiple distinct glob expressions). – Charles Duffy Dec 10 '17 at 19:22
  • @CharlesDuffy I have not much of a clue what I am doing: bash novice. Saw some existing code, needed to tweak that to the desired result. Got an error and related that error to the "exclamation mark". I searched for the exact error and exclamation mark. With over 300 results on Stackoverflow. Gave up after scanning 200. Read a Bash manual, and documented my case at stackoverflow in the hope to find my own q&a a next time. My own stack q&a's saved me several times in the past, even years later. – Pro Backup Dec 10 '17 at 19:28

1 Answers1

3

Extended glob

The pattern you are trying to negate match with the exclamation mark is an "extended glob". Enabled somewhere in the script with a command alike shopt -s extglob.

The negation form with extended globbing syntax is defined as !(list):

!(list) Matches anything but the given patterns.

The inverse of that negative match in this case is the syntaxis @(list):

@(list) Matches one of the given patterns

Pro Backup
  • 729
  • 14
  • 34