【问题标题】:Displaying files matching a certain name format in UNIX在 UNIX 中显示匹配特定名称格式的文件
【发布时间】:2013-09-20 02:21:55
【问题描述】:

使用ls 命令,我试图显示与特定文件名格式匹配的所有文件。我找到了创建各种表达式来匹配的方法,但我无法创建正确的表达式来匹配这种特定格式。

我正在寻找符合以下条件的文件:

  • 以字母开头(任何大小写);
  • 包含一个数字;和
  • 以句点“.”结束后跟一个小写字母和一个字符。

【问题讨论】:

    标签: unix expression ls


    【解决方案1】:

    尝试:

    ls | awk '/^[A-Za-z].*[0-9].*\.[a-z].$/{print $0}'
               ^                              Anchor to the beginning of the file name
                ^^^^^^^^                      Begins with letter
                        ^^                    0 or more any character
                          ^^^^^               A digit
                               ^^             0 or more any character
                                 ^^           literal .
                                   ^^^^^      A lower case letter
                                        ^     any single character
                                         ^    Anchor to the end of the file name
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-01-11
      • 2017-01-03
      • 1970-01-01
      • 2021-11-30
      • 2016-11-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多