Unix wildcard selectors? (Asterisks)

后端 未结 3 1045
清歌不尽
清歌不尽 2020-12-30 00:46

In Ryan Bates\' Railscast about git, his .gitignore file contains the following line:

tmp/**/*

What is the purpose of using the double

3条回答
  •  生来不讨喜
    2020-12-30 01:15

    It says to go into all the subdirectories below tmp, as well as just the content of tmp.

    e.g. I have the following:

    $ find tmp
    tmp
    tmp/a
    tmp/a/b
    tmp/a/b/file1
    tmp/b
    tmp/b/c
    tmp/b/c/file2
    

    matched output:

    $ echo tmp/*
    tmp/a tmp/b
    

    matched output:

    $ echo tmp/**/*
    tmp/a tmp/a/b tmp/a/b/file1 tmp/b tmp/b/c tmp/b/c/file2
    

    It is a default feature of zsh, to get it to work in bash 4, you perform:

    shopt -s globstar
    

提交回复
热议问题