【问题标题】:bash: how to merge files containing digits at certain positionbash:如何合并包含特定位置数字的文件
【发布时间】:2012-07-08 17:03:14
【问题描述】:

我想合并所有在某个位置有一位或两位数字的文件。基本上我想匹配 1-22 的数字。

我用 bash 写:

cat chr[0-9][0-9]{0,}_from6_new_mono.txt >all_autosomes_from6_new_mono.txt

我收到此错误:

cat: chr[0-9][0-9]0_from6_new_mono.txt: No such file or directory

但是文件名看起来像这样:

chr22_from6_new_mono.txt

chr1_from6_new_mono.txt

有人可以告诉我哪里有问题吗?谢谢:)

【问题讨论】:

    标签: regex bash cat


    【解决方案1】:

    使用bash,您可以使用花括号扩展来表示数字范围:

    cat chr{1..22}_from_6_new_mono.txt >merged
    

    【讨论】:

      【解决方案2】:

      你确定,你正确使用了大括号扩展吗?

      查看http://www.gnu.org/software/bash/manual/bashref.html#Brace-Expansion了解更多信息

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-07-27
        • 2012-07-02
        • 1970-01-01
        • 2019-06-26
        • 2014-11-26
        • 1970-01-01
        相关资源
        最近更新 更多