首页 > Linux操作系统 > Linux操作系统 > linux文本文件查看、显示命令
命令使用说明:
例子:
例A: 把 textfile1 的文件内容加上行号后输入 textfile2 这个文件里
#cat -n textfile1 > textfile2
例B: 把 textfile1 和 textfile2 的档案内容加上行号(空白行不加)之后将内容附加到 textfile3
#cat -b textfile1 textfile2 >> textfile3
例C:显示/etc/fstab文件的内容。
#cat /etc/fstab
2、head 查看文件头部内容命令。
命令格式:# head [[选项]] <文件列表>
常用选项:
命令使用说明:
用这个命令主要是用来显示文件我头部内容。以确认是不是我们想要打开或查找的文件。
例子:
例A:比如,我的/mnt/D目录下有一个文件名“readme.txt”,我想看它头几行的内容,可用命令:
# head /mnt/D/readme.txt
Macromedia
Flash Player 6 for Linux
Mozilla Plug-in and Standalone players
Update Version 6.0r79
4 March 2003
New in This Version
-------------------
find for the dir
3、tail 查看文件尾部内容命令。
命令格式:# tail [[选项]] <文件列表>
常用选项:
命令使用说明:
用这个命令主要是用来显示文件我尾部内容。以确认是不是我们想要打开或查找的文件。
例子:
例A:在上例中,若想看后面10行的内容,可用命令:
#tail /mnt/D/readme.txt
2) Browser version
3) Reproducible steps including a URL to the web site where the
problem was encountered.
If we need further information about a bug, you will be contacted. An
automated reply will be sent to assure you that we have received your
bug report. Due to the volume of mail received we are not able to
individually respond to each report.
4、grep 查找文件内容命令。
命令格式:#grep [[选项]] <匹配字符> <文件列表>
常用选项:
命令使用说明:
这个命令主要是用来在终端中显示查找某个特定的字符串,找出与给定模式相匹配的内容。文件列表中,各个文件之间用空格分开。
例子:
例A:在文件example中搜索匹配字符“text file”。
#grep 'text file' example
5、more 分页显示文件命令。
命令格式:more [[选项]] <文件名>
常用选项:
命令使用说明:
用这命令在终端分屏显示文件内容。
例子:
例A:分页显示文件/root/log.txt的内容。
#more /root/log.txt
6、less 分页显示文件命令
命令格式:less [[选项]] <文件名>
常用选项:
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/134012/viewspace-739218/ ,如需转载,请注明出处,否则将追究法律责任。