【发布时间】:2013-10-24 10:50:25
【问题描述】:
我想知道下面两个命令cat 和fold 命令之间的区别?我只是
使用了fold 命令,它的作用类似于cat 命令。
fold file1.txt
cat fold.txt (both are using to display the contents of the file)
【问题讨论】:
我想知道下面两个命令cat 和fold 命令之间的区别?我只是
使用了fold 命令,它的作用类似于cat 命令。
fold file1.txt
cat fold.txt (both are using to display the contents of the file)
【问题讨论】:
fold 命令在cat 显示文本而不换行时换行:
【讨论】:
查看他们的手册页
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 中不存在这样的选项
【讨论】:
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。
【讨论】: