zoukankan      html  css  js  c++  java
  • Linux通配符

    Linux通配符
    说明:通配符是bash的内置功能,几乎适用于所有Linux命令。
    *  匹配任意(0个或多个)字符或字符串,包括空字符串。
    ?  匹配任意1个字符,有且只有一个字符。
    [abcd]  匹配abcd中任何一个字符,abcd也可以是其他任意不连续字符。
    [a-z]  匹配a到z之间的任意一个字符,字符前后要连续,也可以用连续数字,即[1-9]。
    [!abcd]  表示不匹配括号里面的任何一个字符,也可以写为 [!a-d],这里的 "!"号可以用"^" 替代,即[^abcd]
    
    
    通配符"*" 示例:
    [root@testdb62 test]# touch exec.sh liang.log guo.log liang.sql a.sql
    [root@testdb62 test]# ls 
    a.sql  exec.sh  guo.log  liang.log  liang.sql
    
    查看所有结尾为 log 结尾的文件
    [root@testdb62 test]# ls *.log
    guo.log  liang.log
    
    查看所有结尾为 sh 结尾的文件
    [root@testdb62 test]# ls *.sh
    exec.sh
    
    
    通配符"?" 示例:
    [root@testdb62 test]# ls ?.sh
    ls: 无法访问?.sh: 没有那个文件或目录
    [root@testdb62 test]# touch a.sh
    [root@testdb62 test]# ls ?.sh
    a.sh
    [root@testdb62 test]# ls ???.sh
    ls: 无法访问???.sh: 没有那个文件或目录
    [root@testdb62 test]# ls ???.log
    guo.log
    
    
    通配符"[abcd]" 示例:
    [root@testdb62 test]# ls [abcd].sh
    a.sh
    [root@testdb62 test]# ls gu[opq].log
    guo.log
    
    
    通配符"[a-z]" 示例:
    [root@testdb62 test]# touch c.sh d.sh cd.sh 
    [root@testdb62 test]# ls 
    a.sh  cd.sh  c.sh  d.sh  exec.sh  guo.log  liang.log  liang.sql
    [root@testdb62 test]# ls [a-z].sh
    a.sh  c.sh  d.sh
    [root@testdb62 test]# ls [a-z]???.sh
    exec.sh
    [root@testdb62 test]# touch 1 
    [root@testdb62 test]# touch 2
    [root@testdb62 test]# ls [1-9]
    1  2
    
    
    通配符"[!abcd]" 示例:
    [root@testdb62 test]# touch a b c d e f 
    [root@testdb62 test]# ls [^abcd]
    1  2  e  f
    [root@testdb62 test]# ls 
    1  2  a  a.sh  b  c  cd.sh  c.sh  d  d.sh  e  exec.sh  f  guo.log  liang.log  liang.sql
    [root@testdb62 test]# ls [!abcd]
    1  2  e  f
    [root@testdb62 test]# ls [!a-d]
    1  2  e  f
    [root@testdb62 test]# ls [^1-9]
    a  b  c  d  e  f
  • 相关阅读:
    openerp学习笔记 模块结构分析
    Odoo文档管理/知识管理应用实践
    POSTGRESQL DEFAULT TEMPLATE0 НА UTF8 ENCODING
    could not execute command lessc odoo
    XPath 元素及属性查找
    pycharm 使用心得(四)显示行号
    mimetypes.py的UnicodeDecodeError
    win7源码运行odoo8.0错误
    xUtils 中的BitmapUtils 全面注释
    Android初级到高级指南(精华版)
  • 原文地址:https://www.cnblogs.com/l10n/p/14097794.html
Copyright © 2011-2022 走看看