5.1 在标准输出设备上查看文件
cat
DOS用户使用type
命令将文本文件的内容显示在屏幕上。Linux用户则可以使用cat
命令,它做的事情与type
命令一样。想在shell中查看文件吗?试试cat
命令吧。
$ cat Hopkins_-_The_Windhover.txt
I caught this morning morning's minion, kingdom
of daylight's dauphin, dapple-dawn-drawn Falcon, in his riding
Of the rolling level underneath him steady air, and striding
High there, how he rung upon the rein of a wimpling wing
In his ecstasy! then off, off forth on swing,
As a skate's heel sweeps smooth on a bow-bend: the hurl and gliding
Rebuffed the big wind. My heart in hiding
Stirred for a bird, -- the achieve of, the mastery of the thing!
Brute beauty and valour and act, oh, air, pride, plume, here
Buckle! AND the fire that breaks from thee then, a billion
Times told lovelier, more dangerous, o my chevalier!
No wonder of it: sheer plod makes plough down
sillion
Shine, and blue-bleak embers, ah my dear,
Fall, gall themselves, and gash gold-vermilion.
$
cat
命令将文件打印到屏幕,然后直接返回到命令提示符。如果文件长度超出屏幕的范围,必须向上滚动才能看到刚才一闪而过的内容。
这正是使用cat
命令的一个大问题:如果正在查看的文档很长,文件内容在屏幕上飞驰而过,这个过程可能要花不少时间,同时也很难阅读(你能想象这个命令会产生什么:cat Melville_-_Moby_ Dick.txt
)。解决办法就是使用5.5节中介绍的less
命令。