绺

梦在远方,路在脚下
posts - 2, comments - 1, trackbacks - 0, articles - 8

linux文件查看命令集

Posted on 2009-01-19 18:19 栗衙 阅读(335) 评论(0)  编辑  收藏
cat由第一行开始显示文件内容
tac
从最后一行开始显示
nl
显示同时输出行号
more
一页一页的显示内容
less
与more类似,但其优点是,可以往前翻页
head
只看头几行
tail
只看未尾几行
od
以二进制的方式读取文件内容

cat[-n]
-n
连行号一起输出到屏幕上与nl相似

more[
文件名]
more test.txt
将test.txt一页一页的显示出来
ls -al | more
将ls显示的内容一页页显示出来

less[
文件名]
less
的用法比more更有弹性,使用less可以用pageup、pagedown翻看
less test.txt
/word
在test.txt中搜寻word这个字符串
q
:退出less

head[-n number] [
文件名]
-n
显示number行
head -n 20 test.txt
显示test.txt前20行

tail [-n number] [
文件名]
-n
显示number行

tail -n 20 test.txt
显示test.txt后20行


head -n 20 test.txt | tail -n 10
取11-20行

只有注册用户登录后才能发表评论。


网站导航: