Extended Glob: What is the difference in syntax between ?(list), *(list), +(list) and @(list)

fer

I have a question after reading about extended glob.

After using shopt -s extglob,

What is the difference in the following?

?(list): Matches zero or one occurrence of the given patterns.

*(list): Matches zero or more occurrences of the given patterns.

+(list): Matches one or more occurrences of the given patterns.

@(list): Matches one of the given patterns.

Yes, I have read the above description that accompanies them, but for practical purpose, I can't see situations where people would prefer ?(list) over *(list). That is, I don't see any difference.

I've tried the following:

$ ls
> test1.in test2.in test1.out test2.out`

$ echo *(*.in)
> test1.in test2.in

$ echo ?(*.in)
> test1.in test2.in

I'd expect $ echo ?(*.in) to output test1.in only, from the description, but it does not appear to be the case. Thus, could anyone give an example where it makes a difference regarding the type of extended glob used?

Source: http://mywiki.wooledge.org/BashGuide/Patterns#Extended_Globs

Stéphane Chazelas
$ shopt -s extglob
$ ls
abbc  abc  ac
$ echo a*(b)c
abbc abc ac
$ echo a+(b)c
abbc abc
$ echo a?(b)c
abc ac
$ echo a@(b)c
abc

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Difference Between *list and **list

What is the difference between a list of tuples and a list of objects?

What is the difference between list += str and list += str,

What is the difference between ('a * 'a) list and 'a * 'a list in ocaml?

What is the difference between list and list[:] in python?

What's the difference between List<Object> and List<?>

What is the difference between List<Object[]> and List<Object>?

What's the difference between list[::] and list?

What's the difference between list() and []

What is the difference between Set and List?

What is the difference between quote and list?

What is the difference between List and ArrayList?

What is the difference between [[]] and $ in list indexing?

What is the difference between List<Integer[]> and List<List<Integer>> in java

difference between clear list and list = []

Difference between list and list* in Racket

Difference between List, List<?>, List<T>, List<E>, and List<Object>

List and copy of list (what is the difference?)

Difference between branch & bound (+ extended list) and Dijkstra's Algorithm on Graphs

What is the difference between `sorted(list)` vs `list.sort()`?

What is the difference between List<Number> and List<? extends Number>?

What is difference between @+id/android:list and @+id/list

What's the difference between List<Type/*1*/>> and List<Type/*2*/>>

What is the difference between List<Something> and List<? extends Something>?

What is the difference between a cyclic list and an infinite list in haskell?

What is the difference between del a_list[:] and a_list = [] in a function?

What's the difference between a list and a vector whose mode is list?

What is the difference between "for each in list" and "for each in list[0:]"

What's the difference between a const list and unmodifiable List?