二、文件处理命令touch、cat、more、less、head、tail

1、touch:创建空文件(命令所在路径/bin/touch)

eg①:在ao目录内新建一个apple空文件

二、文件处理命令touch、cat、more、less、head、tail

eg②:接上,在ao目录内新建两个空文件,pen和pencil

二、文件处理命令touch、cat、more、less、head、tail

eg③:接上,在ao目录内新建一个空文件,pen and pencil

二、文件处理命令touch、cat、more、less、head、tail


2、cat:显示文件内容(/bin/cat)

选项:-n 显示行号

eg①:显示etc目录下issue中的文件内容

eg②:显示etc目录下issue中的文件内容,并显示行号

二、文件处理命令touch、cat、more、less、head、tail

eg③:显示etc目录下的services中的文件内容

事实上文件特别长,一直在滚动显示,滚动显示停止后,只能显示出最后一页。

二、文件处理命令touch、cat、more、less、head、tail

eg④:逆序显示etc目录下的issue文件内容

如果输入"tac",文件会倒着、逆序显示

二、文件处理命令touch、cat、more、less、head、tail


3、more:分页显示文件内容(/bin/more)

eg①:显示etc目录下的services文件内容

按空格键可以一页一页的翻,%那里会随着页码的增加而增大

按回车键可以一行一行的跳转

按“q”键可以退出

(注:不能往上翻)

二、文件处理命令touch、cat、more、less、head、tail


4、less:分页显示文件内容,可以向上翻(/bin/less)

eg①:显示etc目录下services中的文件内容

按Pageup键可以一页一页往上翻

按“↑”键可以一行一行往上翻

图略

eg②:搜索改文件中的某一个关键词,如tcp

/关键词,如果不在当前页面,可以按“n”查看其它

二、文件处理命令touch、cat、more、less、head、tail

二、文件处理命令touch、cat、more、less、head、tail


5、head:显示文件前面几行(/bin/head)

选项:-n指定行数

eg①:显示etc目录下services中的文件的前5行

二、文件处理命令touch、cat、more、less、head、tail


6、tail:显示文件后面几行(/bin/tail)

选项:-n指定行数

选项:-f动态显示文件末尾内容

eg①:同head,略