栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

Linux常见查看命令

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Linux常见查看命令

目录

1.cat [-nb] fileName

 2.more [-d] [-num] [+/pattern] [+num] [fileName]

 3.less [-MN] [p pattern] fileName

 4.head [-nc] file||tail [-nc] file


1.cat [-nb] fileName

-n 编号
-b 空白行不编号
[-nb] > fileName 写文本
[-nb] file1 > file2 1的内容复制到2,2原内容消失
[-nb] file1 file2 > file 合并重新写入文件
[-nb] file1 file2 >> file3 合并追加到file3

​​[root@localhost桌面]#cat -n file

查看文件并显示行号。

​​[root@localhost桌面]#cat -b file

 查看文件显示行号(空白行不进行编号)

​​[root@localhost桌面]#cat > file

写一个新的文本,如果文本已经存在就重置写入新内容。

​​[root@localhost桌面]#cat file1 > file2

file的内容复制到file2,file2原内容消失

  

​​[root@localhost桌面]#cat file1 file2 > file3

file1的内容和file2的内容合并重新写入文件 file3,file3若不存在,创建file3,若存在则原内容消失。

​​[root@localhost桌面]#cat file1 file2 >> file3

file1的内容和file2的内容合并续写到file3原文件的后面,file3若不存在,创建file3。


 2.more [-d] [-num] [+/pattern] [+num] [fileName]

-d 提示使用者
-num 一次显示的行数
+/pattern 搜寻该字串,从该字串之后开始显示
+num 从第 num 行开始显示
空格 为向下一屏
用d/b向下/上翻阅,退出用q或ctrl+d

​​[root@localhost桌面]#more -d file

当页面不能显示所有信息的时候,会提示使用者当前进度等信息。

​​[root@localhost桌面]#more -n file

一次显示n行。

[root@localhost桌面]#more +/pattern 

查找pattern字符串,在第三行显示找到的字符串行。

[root@localhost桌面]#more +n file

从文件的第n行开始显示。


 
3.less [-MN] [p pattern] fileName

另开页面显示

-M 显示读取文件的百分比、行号及总行数。
-N 在每行前输出行号。
-p pattern 搜索pattern字符串,在它之后显示。

[root@localhost桌面]#less -M file

显示读取文件的百分比、行号及总行数。

 

[root@localhost桌面]#less -N file

显示行号。

[root@localhost桌面]#less -p pattern file

 搜索pattern字符串,在它之后显示。


 4.head [-nc] file||tail [-nc] file

-n num显示num行

-c num显示num个字节

默认显示为10行

head显示头10行,tail显示最后10行

[root@localhost桌面]#head -n num file

从头显示num行

[root@localhost桌面]#head -c num file

从头显示num个字节。

[root@localhost桌面]#tail -n num file

显示最后的num行。

[root@localhost桌面]#tail -c num file

显示最后的num个字节。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/277431.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号