linux常用命令touch,cat,tac,more,less,head,tail

touch

change file timestamps

修改文件最后修改时间

但这并不是重点。
if file argument that does not exist is created empty,unless -c or -h is supplied.
如果文件名不存在的话就会创建一个空文件,除非使用了-c或-h参数
这里我只演示它创建文件和修改时间的功能。
这里写图片描述

cat

concatenate the file and print on the standard output
把文件当中的内容在标准输出设备(显示器)上打印出来.
但是注意它只适合内容量比较少的打印
这里写图片描述
如果内容量比较大的话就不合适了。大家可以自己试一下下面这条语句会产生什么效果

cat /etc/services
-n,–number

这里写图片描述
显示行号

tac

concatenate and print the file in reverse
把文件内容逆序打印出来
为了好记,记住cat(正着写的)就是顺序打印,tac(逆序写的)就是逆序打印
这里写图片描述

more

more is a filter for paging through text one screenful at a time.
more就是一个过滤器,专门用来处理那些一次一个屏幕无法显示的情况。
因为我不会做gif,所以就不上图了
但是这里将几个按键介绍一下,在使用more之后,使用以下按键:
f或者空格键会一页一页显示
回车键会一行一行显示。
但是注意使用more之后无法向上显示,只能一直向下

less

less is a program similar to more ,but which allows backward.
less和more的功能类似,但是它允许回退(也就是向前看)
同时对于less也有一下几个按键:
它的按键和more一样,只不过增加了pageUp可以一页一页向前看,
下键,可以一行一行向前看

print first part of the file
就是显示文章的开头部分
默认情况下回显示前十行

-n

可以指定显示多少行
这里写图片描述

tail

print the last part of the file
显示文章的最后的部分

当然,也有-n参数,我就不演示了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章