【问题标题】:Arguments to -type should contain only one letter-type 的参数应该只包含一个字母
【发布时间】:2018-04-20 13:05:32
【问题描述】:

我正在使用 git-bash 在 win 10 中工作。我有一大组文件,所有这些文件都没有扩展名。但是我已经意识到“文件”类型的那些是 html 文件。要选择这些我试过:

$ find -type "File"
find: Arguments to -type should contain only one letter

如何选择“文件”类型的文件(无论扩展名如何)

【问题讨论】:

    标签: windows bash find git-bash


    【解决方案1】:

    该列中的类型是 Windows 对文件类型的最佳猜测 - 这与 UNIX 实用程序 find 无关:

    find -type f # find all files
    

    将返回屏幕截图中的所有内容,因为它们都是某种类型的文件。

    要匹配所有没有扩展名的文件(其中“扩展名”定义为一个点后的三个小写字母字符),您可以使用:

    find -not -name '*.[a-z][a-z][a-z]'
    

    或者,您可以将模式更改为 *.* 以匹配任何不包含点的文件。

    如果需要,您可以使用正则表达式进行更复杂的操作:

    find -regextype posix-extended -not -iregex '.*/.+\.[a-z]{1,4}'
    

    这匹配任何不以点结尾且后跟一到四个字符的文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-05
      • 1970-01-01
      • 2021-05-16
      相关资源
      最近更新 更多