What do the two asterisks used to specify directories represent?

Asked 1 years ago, Updated 1 years ago, 90 views

** is used as a matter of course without any explanation when you want to express a directory recursively. What is this notation? It doesn't seem to be a regular expression.

Example:
Try implementing user authentication with Spring Security - Momoiro Technology

.antMatchers("/**").hasRole("USER")

Wildcard Mappings

**Matches zero or more characters including the slash('/') character.

In many examples, * is called a wildcard, but did it originate in shell?

I can guess that ^ or $ can be used in addition to * (although there must be several schools of regular expression writing). Similarly, if * is used instead of this regular expression, what other symbols might be used?

linux apache spring-security

2022-09-30 21:48

3 Answers

It seems a little different from the example of how to use the question, but it seems that zsh originated.
The title of the article is Recursive Glob Pattern, Recursive Directory Search, and Recursive Globbing in the zsh documentation linked from the article.

Checked to see if the recursive glob pattern**/ originated from zsh

At first, it was.../!

Zsh-2.1 changed to ****/

Zsh-2.2 to **/

On May 14, 1992, isn't zsh the original?I could see that

zsh documentation 14.8.6 Recursive Globbing

The following Q&A article is also titled "recursive globbing."

recursive globbing**/* and*/**

I am learning the wildcards recurring globbing and tried

In this answer and the link below, '**' seems to be referred to as 'globstar' or 'globstar expansion'.

Also beware that in zsh (the original implementation of recurring globbing), ...only **/ is (short for (*/)#) ...See The result of ls*,ls** and ls*** for details.

And in all of the articles/manuals/comments above, **/ is an abbreviation of (*/)#, and # is the same specification as the regular expression * in the zsh manual.
That's why I think I can say regular expressions.

14.8.1 Glob Operators at the end

x#

(Requires EXTENDED_GLOB to be set.) Matches zero or more occurrences of the pattern x. This operator has high precedence; '12#' is equivalent to'1(2#)', father than'(12)#'.

The first appearance of questions and other answers is usually later than zsh, so it can be said that it originated in zsh.
Apache for httpd is 1995, rsync is 1996, Apache Ant is 2000, Spring Framework is 2002.

'**' is included in rsync and appears in Apache Ant in one line of build.xml.

rsync(1)-Linux man page
Apache Ant-Wikipedia

By the way, Python has been supported since 3.5, so it's relatively recent.
glob---Pathname Pattern Expansion in Unix Format

glob.glob(pathname,*,recursive=False)
If recursive is true, the pattern "**" matches symbolic links to any file or more than 0 directories, subdirectories, and directories.
Changed in version 3.5: recursive glob with "**" was supported.

Recursive or not is optional in glob, but in pathlib it is recursive with a definite hit.
pathlib --- object-oriented file system path

The pattern "**" means "recursively scan this directory and all subdirectories."In other words, recursive Glob scanning is possible:

Filename originated as a wildcard in the 1960s.
CTSS is 1961, TOPS-10 is 1967, and Multics and UNIX are 1969.

Earlist use of an asterisk(*) to indicate a zero-to-many character wildcard?
Comments based on regular expressions from around 1956

It was injected by Stephen Kleene around 1956 as part of the specifications for regular expressions; it's called the "Kleene star"–aure"Kleen."

The answer is quoted as being based on TOPS-10 and Multics.

TOPS-10 syntax (precursor of MS-DOS)

Multicsyntax (precursor of UNIX and modern Microsoft Windows)

There seems to have been another concept of wildcard in CTSS.
Compatible Time-Sharing System-Wikipedia

  • delete – Delete file, had*wildcards

For UNIX, as mentioned in the Origin section here, the program called /etc/glob independent of the interpreter seems to be the first one.
Glob-Wikipedia


2022-09-30 21:48

When I want to express a directory recursively, ** is used as if it were natural without any explanation. What is this notation? I don't think it's a regular expression.

I think it's a wildcard application that can be used when specifying the file set of "ant".*The reason is that the first time I saw the expression ** was "ant".
 The regular expression * is not used alone, so you should consider it different from the regular expression.
 I think the single * comes from the wildcard of the glob, and I think ** is the extension (just guess).
 I have seen the description that * contains any string that does not contain / and ** contains /.
 When the file path delimiter is /, ** matches across directories, so we use it as a wildcard to match files directly under and under directories.


2022-09-30 21:48

File and directory name pattern notation such as *, ?, [a-z] comes from the shell のpathname expansion 「 or ファイルfilename expansion ) and the C function pathname pattern match (glob(3)).This is not a regular expression.

There are several dialects and extensions in pathname expansion and pathname pattern matches, among which ** matches any string, including / may be derived from rsync (1).(I don't know the reason or source)


2022-09-30 21:48

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.