代码: 全选
# [color=RoyalBlue][B]ls -la > 123[/B][/color]
代码: 全选
# [B][color=RoyalBlue]cat 123[/color][/B]
total 616
drwxr-xr-x 2 root wheel 512 Apr 14 16:25 .
drwxr-xr-x 5 root wheel 512 Apr 14 16:20 ..
-rw-r--r-- 1 root wheel 0 Apr 14 16:25 123
-rw-r--r-- 1 root wheel 54219 Apr 11 05:02 discuz-001.png
-rw-r--r-- 1 root wheel 60373 Apr 11 05:02 discuz-002.png
-rw-r--r-- 1 root wheel 54898 Apr 11 05:02 discuz-003.png
-rw-r--r-- 1 root wheel 49146 Apr 11 05:02 discuz-004.png
-rw-r--r-- 1 root wheel 40072 Apr 11 05:02 discuz-005.png
-rw-r--r-- 1 root wheel 48526 Apr 11 05:02 discuz-006.png
下面的命令将123的内容直接赋予456
代码: 全选
# [color=RoyalBlue][B]cat 123 > 456[/B][/color]
我们看一下456的内容:
代码: 全选
# [color=RoyalBlue][B]cat 456[/B][/color]
total 616
drwxr-xr-x 2 root wheel 512 Apr 14 16:25 .
drwxr-xr-x 5 root wheel 512 Apr 14 16:20 ..
-rw-r--r-- 1 root wheel 0 Apr 14 16:25 123
-rw-r--r-- 1 root wheel 54219 Apr 11 05:02 discuz-001.png
-rw-r--r-- 1 root wheel 60373 Apr 11 05:02 discuz-002.png
-rw-r--r-- 1 root wheel 54898 Apr 11 05:02 discuz-003.png
-rw-r--r-- 1 root wheel 49146 Apr 11 05:02 discuz-004.png
-rw-r--r-- 1 root wheel 40072 Apr 11 05:02 discuz-005.png
-rw-r--r-- 1 root wheel 48526 Apr 11 05:02 discuz-006.png
代码: 全选
# [B][color=RoyalBlue]cat 123 >> 456[/color][/B]
代码: 全选
#[color=RoyalBlue] [B]cat 456[/B][/color]
total 616
drwxr-xr-x 2 root wheel 512 Apr 14 16:25 .
drwxr-xr-x 5 root wheel 512 Apr 14 16:20 ..
-rw-r--r-- 1 root wheel 0 Apr 14 16:25 123
-rw-r--r-- 1 root wheel 54219 Apr 11 05:02 discuz-001.png
-rw-r--r-- 1 root wheel 60373 Apr 11 05:02 discuz-002.png
-rw-r--r-- 1 root wheel 54898 Apr 11 05:02 discuz-003.png
-rw-r--r-- 1 root wheel 49146 Apr 11 05:02 discuz-004.png
-rw-r--r-- 1 root wheel 40072 Apr 11 05:02 discuz-005.png
-rw-r--r-- 1 root wheel 48526 Apr 11 05:02 discuz-006.png
total 616
drwxr-xr-x 2 root wheel 512 Apr 14 16:25 .
drwxr-xr-x 5 root wheel 512 Apr 14 16:20 ..
-rw-r--r-- 1 root wheel 0 Apr 14 16:25 123
-rw-r--r-- 1 root wheel 54219 Apr 11 05:02 discuz-001.png
-rw-r--r-- 1 root wheel 60373 Apr 11 05:02 discuz-002.png
-rw-r--r-- 1 root wheel 54898 Apr 11 05:02 discuz-003.png
-rw-r--r-- 1 root wheel 49146 Apr 11 05:02 discuz-004.png
-rw-r--r-- 1 root wheel 40072 Apr 11 05:02 discuz-005.png
-rw-r--r-- 1 root wheel 48526 Apr 11 05:02 discuz-006.png
我们在456这个文件中增加几个空行,让它变成这样:
代码: 全选
total 616
drwxr-xr-x 2 root wheel 512 Apr 14 16:25 .
drwxr-xr-x 5 root wheel 512 Apr 14 16:20 ..
-rw-r--r-- 1 root wheel 0 Apr 14 16:25 123
-rw-r--r-- 1 root wheel 54219 Apr 11 05:02 discuz-001.png
-rw-r--r-- 1 root wheel 60373 Apr 11 05:02 discuz-002.png
-rw-r--r-- 1 root wheel 54898 Apr 11 05:02 discuz-003.png
-rw-r--r-- 1 root wheel 49146 Apr 11 05:02 discuz-004.png
-rw-r--r-- 1 root wheel 40072 Apr 11 05:02 discuz-005.png
-rw-r--r-- 1 root wheel 48526 Apr 11 05:02 discuz-006.png
total 616
drwxr-xr-x 2 root wheel 512 Apr 14 16:25 .
drwxr-xr-x 5 root wheel 512 Apr 14 16:20 ..
-rw-r--r-- 1 root wheel 0 Apr 14 16:25 123
-rw-r--r-- 1 root wheel 54219 Apr 11 05:02 discuz-001.png
-rw-r--r-- 1 root wheel 60373 Apr 11 05:02 discuz-002.png
-rw-r--r-- 1 root wheel 54898 Apr 11 05:02 discuz-003.png
-rw-r--r-- 1 root wheel 49146 Apr 11 05:02 discuz-004.png
-rw-r--r-- 1 root wheel 40072 Apr 11 05:02 discuz-005.png
-rw-r--r-- 1 root wheel 48526 Apr 11 05:02 discuz-006.png
代码: 全选
# [color=RoyalBlue][B]cat -s 456[/B][/color]
total 616
drwxr-xr-x 2 root wheel 512 Apr 14 16:25 .
drwxr-xr-x 5 root wheel 512 Apr 14 16:20 ..
-rw-r--r-- 1 root wheel 0 Apr 14 16:25 123
-rw-r--r-- 1 root wheel 54219 Apr 11 05:02 discuz-001.png
-rw-r--r-- 1 root wheel 60373 Apr 11 05:02 discuz-002.png
-rw-r--r-- 1 root wheel 54898 Apr 11 05:02 discuz-003.png
-rw-r--r-- 1 root wheel 49146 Apr 11 05:02 discuz-004.png
-rw-r--r-- 1 root wheel 40072 Apr 11 05:02 discuz-005.png
-rw-r--r-- 1 root wheel 48526 Apr 11 05:02 discuz-006.png
total 616
drwxr-xr-x 2 root wheel 512 Apr 14 16:25 .
drwxr-xr-x 5 root wheel 512 Apr 14 16:20 ..
-rw-r--r-- 1 root wheel 0 Apr 14 16:25 123
-rw-r--r-- 1 root wheel 54219 Apr 11 05:02 discuz-001.png
-rw-r--r-- 1 root wheel 60373 Apr 11 05:02 discuz-002.png
-rw-r--r-- 1 root wheel 54898 Apr 11 05:02 discuz-003.png
-rw-r--r-- 1 root wheel 49146 Apr 11 05:02 discuz-004.png
-rw-r--r-- 1 root wheel 40072 Apr 11 05:02 discuz-005.png
-rw-r--r-- 1 root wheel 48526 Apr 11 05:02 discuz-006.png
加上-n参数表示显示时加上行号:
代码: 全选
# [color=RoyalBlue][B]cat -n 456[/B][/color]
1 total 616
2 drwxr-xr-x 2 root wheel 512 Apr 14 16:25 .
3 drwxr-xr-x 5 root wheel 512 Apr 14 16:20 ..
4 -rw-r--r-- 1 root wheel 0 Apr 14 16:25 123
5 -rw-r--r-- 1 root wheel 54219 Apr 11 05:02 discuz-001.png
6 -rw-r--r-- 1 root wheel 60373 Apr 11 05:02 discuz-002.png
7 -rw-r--r-- 1 root wheel 54898 Apr 11 05:02 discuz-003.png
8 -rw-r--r-- 1 root wheel 49146 Apr 11 05:02 discuz-004.png
9 -rw-r--r-- 1 root wheel 40072 Apr 11 05:02 discuz-005.png
10 -rw-r--r-- 1 root wheel 48526 Apr 11 05:02 discuz-006.png
11
12
13
14
15 total 616
16 drwxr-xr-x 2 root wheel 512 Apr 14 16:25 .
17 drwxr-xr-x 5 root wheel 512 Apr 14 16:20 ..
18 -rw-r--r-- 1 root wheel 0 Apr 14 16:25 123
19 -rw-r--r-- 1 root wheel 54219 Apr 11 05:02 discuz-001.png
20 -rw-r--r-- 1 root wheel 60373 Apr 11 05:02 discuz-002.png
21 -rw-r--r-- 1 root wheel 54898 Apr 11 05:02 discuz-003.png
22 -rw-r--r-- 1 root wheel 49146 Apr 11 05:02 discuz-004.png
23 -rw-r--r-- 1 root wheel 40072 Apr 11 05:02 discuz-005.png
24 -rw-r--r-- 1 root wheel 48526 Apr 11 05:02 discuz-006.png
代码: 全选
# [color=RoyalBlue][B]cat -b 456[/B][/color]
1 total 616
2 drwxr-xr-x 2 root wheel 512 Apr 14 16:25 .
3 drwxr-xr-x 5 root wheel 512 Apr 14 16:20 ..
4 -rw-r--r-- 1 root wheel 0 Apr 14 16:25 123
5 -rw-r--r-- 1 root wheel 54219 Apr 11 05:02 discuz-001.png
6 -rw-r--r-- 1 root wheel 60373 Apr 11 05:02 discuz-002.png
7 -rw-r--r-- 1 root wheel 54898 Apr 11 05:02 discuz-003.png
8 -rw-r--r-- 1 root wheel 49146 Apr 11 05:02 discuz-004.png
9 -rw-r--r-- 1 root wheel 40072 Apr 11 05:02 discuz-005.png
10 -rw-r--r-- 1 root wheel 48526 Apr 11 05:02 discuz-006.png
11 total 616
12 drwxr-xr-x 2 root wheel 512 Apr 14 16:25 .
13 drwxr-xr-x 5 root wheel 512 Apr 14 16:20 ..
14 -rw-r--r-- 1 root wheel 0 Apr 14 16:25 123
15 -rw-r--r-- 1 root wheel 54219 Apr 11 05:02 discuz-001.png
16 -rw-r--r-- 1 root wheel 60373 Apr 11 05:02 discuz-002.png
17 -rw-r--r-- 1 root wheel 54898 Apr 11 05:02 discuz-003.png
18 -rw-r--r-- 1 root wheel 49146 Apr 11 05:02 discuz-004.png
19 -rw-r--r-- 1 root wheel 40072 Apr 11 05:02 discuz-005.png
20 -rw-r--r-- 1 root wheel 48526 Apr 11 05:02 discuz-006.png