linux head tail cut 命令
2016-08-22 01:27
555 查看
head
默认输出文件内容的前10行
NAME
- output the first part of files
SYNOPSIS( 大纲,摘要)
- head [option]... [file]...
参数
-n 指定行
-c --bytes
-v 显示文件的文件名
默认输出文件内容的后10行
NAME
- output the last part of files
SYNOPSIS
- tail [option]... [file]...
参数
-n 指定行
-f --follow
output appended data as the file grows
切割:cut命令默认是以tab键作为分割符,但是,只支持单个分割符!
NAME
- remove sections(区段) from each line of files
SYNOPSIS
- cut option... [file]...
参数
-b --bytes 字节
-c --characters 字符
#1个英文字符 = 1个字节
#1个中文字符 = 2个字节
-d --delimiter 指定分割符(默认是以tab键作为分割符)
-f --fields 指定分割的区域(常和-d参数配合使用)
默认输出文件内容的前10行
NAME
- output the first part of files
SYNOPSIS( 大纲,摘要)
- head [option]... [file]...
参数
-n 指定行
-c --bytes
-v 显示文件的文件名
#显示前5行 head -n 5 /etc/inittab head -5 /etc/inittab #只需要掌握这条命令即可
#显示前5个字节 head -c 5 /etc/inittab
#除去最后10行,其它内容都输出 head -n -10 /etc/inittab
#同时查看多个文件的前10行 head /etc/inittab /etc/services
#显示文件的文件名 head -v /etc/inittabtail
默认输出文件内容的后10行
NAME
- output the last part of files
SYNOPSIS
- tail [option]... [file]...
参数
-n 指定行
-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 filecut
切割:cut命令默认是以tab键作为分割符,但是,只支持单个分割符!
NAME
- remove sections(区段) from each line of files
SYNOPSIS
- cut option... [file]...
参数
-b --bytes 字节
-c --characters 字符
#1个英文字符 = 1个字节
#1个中文字符 = 2个字节
-d --delimiter 指定分割符(默认是以tab键作为分割符)
-f --fields 指定分割的区域(常和-d参数配合使用)
#练习素材 echo "I am oldboy my qq is 1234567" >test.txt
#按字节切割(按字符切割操作同理,如果有中文,一定要指定-c参数,否则会出现乱码) 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 thisistabline. this is space line. #把tab键显示出来 cat -T test.txt #参数T:显示tab键 ^I sed -n 1 test.txt #参数n:取消默认输出 参数L:打印不可见字符 \t(tab) $(空格) #cut命令默认是以tab键作为分割符(awk命令默认是以空格作为分割符) cut -f2-3 test.txt #指定空格为分割符 cut -d ' ' -f2-3 test.txt #注意:cut命令只支持单个分割符!
相关文章推荐
- linux cat,tac,more,less,head,tail,cut,sort,uniq,wc,tr命令的使用
- linux-12基本命令之 cat,more,head, tail ,tr,od,wc,cut,diff
- Linux之head、tail、grep、cut等命令详解
- linux常用命令学习之head/tail命令
- Linux命令整理5,sort,awk,head,tail命令
- Linux的tail 与head 命令
- Linux文本查看命令 cat ,more ,less ,head,tail
- Linux命令温故而知新:tail,head,cat
- linux的head和tail命令
- linux中使用head命令和tail命令查看文件中的指定行
- Linux基础文本查看命令之 cat,tac,more,less,head,tail
- Linux常见命令(head,tail)
- linux常用命令简单介绍(netstat,awk,top,tail,head,less,more,cat,nl)
- linux下的head命令和tail命令
- Linux中cat、more、less、head、tail内容查看命令解析与比较
- 在linux中使用head命令和tail命令查看文件中的指定行
- Linux 常用命令——cat, tac, nl, more, less, head, tail, od
- linux用于查看文件内容 tail、cat、more、less、head 、sed 命令
- linux用于查看文件内容 tail、cat、more、less、head 、sed 命令
- 【linux-命令】tail命令,head命令,df命令,df -k、ps命令,ps -ef