(八)资料撷取:head、tail
资料撷取:取出前面(head)与取出后面(tail)文字的功能
head(取出前几行)
写法:head [-n number] 档案
参数: -n:后面接数字,代表显示几行的意思
1 [root@localhost ~]# head -n 5 /etc/man.config 2 # 3 # Generated automatically from man.conf.in by the 4 # configure script. 5 # 6 # man.conf from man-1.6f 7 [root@localhost ~]#
tail(取出后面几行)
写法:tail [-n number] 档案
参数: -n:后面接数字,代表显示几行的意思
1 [root@localhost ~]# tail -n 5 /etc/man.config 2 # /etc/cron.weekly/makewhatis.cron 3 # will not update makewhatis database. 4 # Otherwise the database will be updated. 5 # 6 #MAKEWHATISDBUPDATES n 7 [root@localhost ~]#
如何取/etc/man.config文件的第11行到第20行? head -n 20 /etc/man.config | tail -n 10
1 [root@localhost ~]# head -n 20 /etc/man.config | tail -n 10 2 # when MANPATH contains an empty substring), to find out where the cat 3 # pages corresponding to given man pages should be stored, 4 # and to map each PATH element to a manpath element. 5 # It may also record the pathname of the man binary. [This is unused.] 6 # The format is: 7 # 8 # MANBIN pathname 9 # MANPATH manpath_element [corresponding_catdir] 10 # MANPATH_MAP path_element manpath_element 11 # 12 [root@localhost ~]#


浙公网安备 33010602011771号