文件操作与重定向全解析
在日常的文件操作中,我们常常需要借助各种工具和命令来完成特定的任务。本文将详细介绍一些实用的文件操作命令及其使用场景,帮助你更高效地处理文件。
1. 文件行号显示
在处理代码、配置文件或其他文本文件时,查看每行的行号是很有用的。 cat 命令的 -n 选项可以实现这一功能。
$ cat -n file1 file2
1 this is file1
2
3 it has four lines.
4 the second is blank.
5 this is file2
6
7 it has six lines (three blank)
8
9
10 of which this is the sixth.
如果要为每个文件单独编号,需要为每个文件使用一个 cat 命令,命令之间用分号分隔:
$ cat -n file1 ; cat -n file2
1 this is file1
2
3 it has four lines.
4 the second is blank.
1 this is file2
2
3 it has six lines (three blan
超级会员免费看
订阅专栏 解锁全文
915

被折叠的 条评论
为什么被折叠?



