Linux headtail命令
? head與tail都是以行為單位進(jìn)行數(shù)據(jù)選取的,head是取出前面,tail是取出后面的。
head(取出前面幾行)
1.命令格式:
? ?head [參數(shù)]... [文件]... ?
2.命令參數(shù):
? ?-q 隱藏文件名
? ?-v 顯示文件名
? ?-c<字節(jié)> 顯示字節(jié)數(shù)
? ?-n<行數(shù)> 顯示的行數(shù)
命令示例:
1.默認(rèn)情況下,顯示前10行
[root@w?zdw]#?head?123.log? 1 2 3 4 5 6 7 8 9 102.顯示前5行
[root@w?zdw]#?head?-n?5?123.log? 1 2 3 4 53.文件有21行,以下操作,只打印前面的6行,后面的15行不會(huì)打印出來
[root@w?zdw]#?head?-n?-15?123.log??? 1 2 3 4 5 6tail(取出后面幾行)
1.命令格式;
tail[必要參數(shù)][選擇參數(shù)][文件] ??
2.命令參數(shù):
? ?-f 循環(huán)讀取
? ?-q 不顯示處理信息
? ?-v 顯示詳細(xì)的處理信息
? ?-c<數(shù)目> 顯示的字節(jié)數(shù)
? ?-n<行數(shù)> 顯示行數(shù)
? ?--pid=PID 與-f合用,表示在進(jìn)程ID,PID死掉之后結(jié)束.?
? ?-q, --quiet, --silent 從不輸出給出文件名的首部?
? ?-s, --sleep-interval=S 與-f合用,表示在每次反復(fù)的間隔休眠S秒?
命令示例:
1.顯示文件最后5行
[root@w?zdw]#?tail?-n?5?123.log? 16 17 18 19 202.只列出15行以后的數(shù)據(jù)
[root@w?zdw]#?tail?-n?+15?123.log?? 15 16 17 18 19 203.循環(huán)查看文件內(nèi)容
[root@w?zdw]#?ping?www.baidu.com?>123.log?&???????????把ping信息追加到123.log中 [root@w?zdw]#?tail?-f?123.log? 64?bytes?from?220.181.111.188:?icmp_seq=32?ttl=55?time=3.50?ms 64?bytes?from?220.181.111.188:?icmp_seq=33?ttl=55?time=3.67?ms 64?bytes?from?220.181.111.188:?icmp_seq=34?ttl=55?time=7.14?ms 64?bytes?from?220.181.111.188:?icmp_seq=47?ttl=55?time=3.54?ms 64?bytes?from?220.181.111.188:?icmp_seq=48?ttl=55?time=3.33?ms 64?bytes?from?220.181.111.188:?icmp_seq=49?ttl=55?time=4.24?ms ^C一直顯示,直到按ctrl+c才終止
4.顯示文件的第6行到第10行
[root@w?zdw]#?head?-n?10?456.log|tail?-n?5???????使用管道來操作 6 7 8 9 10轉(zhuǎn)載于:https://blog.51cto.com/zhaodongwei/1765474
《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的Linux headtail命令的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 关于curl: (2) Failed I
- 下一篇: linux内核自旋锁API