文件查看类命令:cat, tac, head, tail, more, less
分屏查看命令:more、less
more命令:
[root@centos7 ~]# more anaconda-ks.cfg
特点:翻屏至文件尾部自动退出
按键b:向上翻阅
less命令:
[root@centos7 ~]# less anaconda-ks.cfg
特点:可以上下翻阅,尾部不会自动退出
按键b:向上,空格向下
按键q:退出
查看文件头尾指定行数命令:head、tail
head命令:查看文件的前n行
head [options] FILE
选项:
-n #:查看多少行
[root@centos7 ~]# head -n2 anaconda-ks.cfg
-#:可以省略n选项,直接跟数字,其效果一样
[root@centos7 ~]# head -2 anaconda-ks.cfg
注:
1.不加-n参数直接输入查看的行数等同于-n #
2.不加-n #参数,默认查看10行内容
tail命令:查看文件的后n行
tail [options] FILE
选项:
-n N:查看多少行
-f:实时追加打印内容并不退出(可用ctrl +c退出)
[root@centos7 ~]# tail -f anaconda-ks.cfgnstall.log
注:
1.不加-n参数直接输入查看的行数等同于-n N
2.不加-n N参数,默认查看10行内容
文件管理工具:stat、touch、cp, mv, rm
stat命令:
stat - display file or file system status
格式:
stat FILE...
[root@centos7 ~]# stat anaconda-ks.cfg
文件:两类数据
元数据:metadata(文件描述信息)
数据:data(文件内容本身)
时间戳说明:
Access: 2017-02-24 16:35:11.258671363 +0800
最近一次访问时间(atime)
Modify: 2016-11-02 17:05:26.556971732 +0800
最近一次更改时间(内容)(mtime)
Change: 2016-11-02 17:05:26.556971732 +0800
最近一次改动时间(文件元数据)(ctime)
注:当时间戳发生变化时,元数据一定会发生变化
touch命令:
touch - change file timestamps
格式:
touch [OPTION]... FILE...
[root@centos7 ~]# touch hello
-rw-r--r-- 1 root root 0 Feb 25 08:14 hello
选项:
-c:指定的文件路径不存在时不创建
-a:仅修改atime时间
-m:仅修改mtime时间
-t:修改时间戳
~]# touch -m -t 201605101755 install.log
[[CC]YY]MMDDhhmm[.ss]
修改mtime时间:年月日时分
注:ctime是无法手动修改,当atime或mtime发生变化,ctime自动变动
未完!!!
本文出自 “变相怪杰” 博客,请务必保留此出处http://waldenkk.blog.51cto.com/2410270/1905066
原文:http://waldenkk.blog.51cto.com/2410270/1905066