Linux - Shell - Wildcard

  1. Outline
    1. Wildcards
  2. background
    1. It has been hard to tell wildcards and regular
    2. Wildcard is a simple means to find
      1. When bother with regular, it is a good way
  3. ready
    1. the
      1. centos7
    2. table of Contents
      1. /etc
    3. command
      1. ls -d
        1. -d
          1. If you filter out the directory, ls directory will not unpacking
          2. If you do not follow regular, returns only.

1. wildcard

  1. Outline
    1. Wildcards
    2. wildcard
      1. Wild card?
  2. Wildcards
    1. description
      1. A character
        1. Can in the search, instead of any other character
    2. benefit
      1. Improve the flexibility and efficiency of the search
  3. scenes to be used
    1. ls
    2. find
    3. Other welcome supplement

2. * wildcard

  1. Outline
      • Wildcards
  2. effect
    1. Match any type of [0, + infinity] characters.
      1. Of course, linux path length, there is an upper limit
  3. Scenario 1: match a specific file suffixes

    # . 在通配符里, 是 普通字符, 不要和 正则 弄混了
    # .conf
    > ls -d *.conf
    # .d
    > ls -d *.d
  4. Scenario 2: match specific prefix file

    # sys
    > ls -d sys*

3.? Wildcard

  1. Outline
    1. ? Wildcard
  2. effect
    1. Match any type of single character
  3. Scene: Find suffix length fixed content

    # 后缀长度为 1
    > ls -d *.?

4. [] wildcard

  1. Outline
    1. [] Wildcard
  2. effect
    1. Matches a single character within []
  3. Scenes

    > ls -d [a-z]*
    > ls -d *[a-z]*
    > ls -d *[A-Z]*
    > ls -d *[0-9]*
    > ls -d *[a-Z]*
    > ls -d *[a-f]*
    > ls -d *[a-fxyz]*
    > ls -d *[a-zA-Z0-9]*

5. [!] Wildcard

  1. Outline
    1. [!] Wildcard
  2. effect
    1. Anti menu characters
  3. Scenes

    # 不是 小写字母开头 的文件
    > ls -d [!a-z]

5. {}

  1. Outline
    1. {}
    2. This seems not a wildcard
      1. But many local wildcard, you can also use
  2. effect
    1. Selecting a plurality of yige in str
  3. Scenes

    # 查找 sysco 或者 sysct 开头的 目录 或 文件
    > ls -d sys{co,ct}*

6. Other

  1. In fact, even these things, but I'm not sure whether they belong to the wildcard, not sure how to use
    1. [:alpha:]
    2. other

ps

  1. ref
    1. How to Use Wildcards
    2. Wildcards
    3. Linux articles: Wildcard application
    4. Linux wildcard
  2. Follow-up
    1. Probably before finishing the regular, then move out of it

Guess you like

Origin www.cnblogs.com/xy14/p/12066952.html