【问题标题】:Difference between cat and fold unix commandcat 和 fold unix 命令的区别
【发布时间】:2013-10-24 10:50:25
【问题描述】:

我想知道下面两个命令catfold 命令之间的区别?我只是 使用了fold 命令,它的作用类似于cat 命令。

fold file1.txt
cat fold.txt (both are using to display the contents of the file)

【问题讨论】:

    标签: unix cat


    【解决方案1】:

    fold 命令在cat 显示文本而不换行时换行:

    【讨论】:

      【解决方案2】:

      查看他们的手册页

      man fold
      fold - wrap each input line to fit in specified width
      
      man cat
      cat - concatenate files and print on the standard output
      

      显然fold 可以指定宽度,而cat 中不存在这样的选项

      【讨论】:

        【解决方案3】:

        fold - 折叠线过滤器。这会将行中断为具有最大 x 宽度的列位置(或字节)。

        Example : fold -5 myfile.txt > newfile.txt

        在上面的命令中,这会将 myfile.txt 的行折叠为 5 个字符宽度,并将结果重新路由到文件 newfile.txt

        cat - 允许你读取文件的内容

        Example : cat file1.txt file2.txt > file3.txt

        读取 file1.txt 和 file2.txt 并将这些文件组合成 file3.txt。

        【讨论】:

        • 谢谢@fedorqui。是的,我们不能
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-07-27
        • 1970-01-01
        • 2017-03-14
        • 2012-07-16
        • 1970-01-01
        • 1970-01-01
        • 2020-07-25
        相关资源
        最近更新 更多