• 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
  • 相关阅读:
    关于unity的一个不错的插件平台
    erlang otp中的socket参数设置
    android开发国内镜像
    composer中文镜像
    bootstrap的一些资源
    根据现有表操作基于active record的model
    Erlang Web 监控工具
    erlang程序发布的时候需要注意的地方
    pcl学习笔记(二):点云类型
    c++中inline函数的意义
  • 原文地址:https://www.cnblogs.com/l10n/p/14097794.html
Copyright © 2020-2023  润新知