==================head==================
The first 10 lines of the default output file contents
NAME
-Output the first part of the files
Synopsis (outline, abstract)
-head [option] ... [File] ...
Parameters
-N Specify row
-C--bytes
-V Show file name
-------------------------------
#显示前5行
Head-n 5/etc/inittab
Head-5/etc/inittab #只需要掌握这条命令即可
-------------------------------
#显示前5个字节
Head-c 5/etc/inittab
-------------------------------
#除去最后10行, all other content is output
Head-n -10/etc/inittab
-------------------------------
#同时查看多个文件的前10行
Head/etc/inittab/etc/services
-------------------------------
#显示文件的文件名
Head-v/etc/inittab
==================tail==================
The following 10 lines of the default output file contents
NAME
-Output the last part of the files
Synopsis
-tail [option] ... [File] ...
Parameters
-N Specify row
-F--follow
Output appended data as the file grows
-------------------------------
#显示后5行
Tail-5/etc/inittab
-------------------------------
#动态实时的显示文件的内容
Tail-f Test.log
Tailf Test.log
#tailf是单独的命令: Follow the growth of a log file
==================cut==================
Cut: The Cut command defaults to the TAB key as the delimiter, but only supports a single separator!
NAME
-Remove sections (section) from each line of files
Synopsis
-Cut option ... [File] ...
Parameters
-B--bytes bytes
-C--characters Character
#1个英文字符 = 1 bytes
#1个中文字符 = 2 bytes
-D--delimiter Specifies the delimiter (by default, the TAB key is the separator)
-F--fields Specifies the segmented area (used with the-D parameter)
-------------------------------
#练习素材
echo "I am Oldboy my qq is 1234567" >test.txt
-------------------------------
#按字节切割 (cut by character Similarly, if you have Chinese, be sure to specify the-c parameter, otherwise garbled)
Cut-b 3 Test.txt
Cut-b 3-4 Test.txt
Cut-b-4 Test.txt
Cut-b 4-test.txt
Cut-b 1,4-test.txt
Cut-b -4,4-test.txt
-------------------------------
#切割出来指定的域
Head-1/etc/passwd|cut-d:-f4
-------------------------------
#修改练习素材
Cat >test.txt<<eof
This isthetab line.
This was space line.
#把tab键显示出来
Cat-t test.txt #参数T: Show Tab key ^i
Sed-n 1 test.txt #参数n: Cancel default output parameter L: print invisible character \ t (tab) $ (space)
#cut命令默认是以tab键作为分割符 (the awk command defaults to a space as a separator)
Cut-f2-3 Test.txt
#指定空格为分割符
Cut-d '-f2-3 test.txt
#注意: The Cut command supports only single separators!
This article is from the "Chen was 007" blog, please be sure to keep this source http://chenfage.blog.51cto.com/8804946/1840936
Linux Head Tail Cut command