如何顯示最後幾行行號? - Linux

Puput avatar
By Puput
at 2014-09-01T23:32

Table of Contents

想請問各位,

在 shell 指令裡面我知道可以用 tail 來顯示檔案的最後幾行,

也可以用 wc 來查詢檔案總共有幾行,

可是要是今天我有一個檔案是有數百萬行, 而我又想知道這個檔案到底有幾行時,

用 wc 查詢就要等很久才能知道結果,

而用 tail 的話可以很快就顯示最後幾行的內容, 可是卻不知道行號

用 cat -n | tail 也一樣會等很久

請問有沒有甚麼方法可以很快的查詢一個大檔案的行數, 同時又可以顯示最後幾行

的內容呢?

謝謝各位喔!

--
Tags: Linux

All Comments

Ingrid avatar
By Ingrid
at 2014-09-02T23:47
看來是I/O瓶頸,沒法可治
Elvira avatar
By Elvira
at 2014-09-03T16:37
檔案每行長度固定嗎?
Genevieve avatar
By Genevieve
at 2014-09-06T15:31
去計算一個檔案裡有幾個換行符號呢?會比較快嗎?
Lydia avatar
By Lydia
at 2014-09-08T09:51
不會,因為讀全個檔案這一步太慢了,其他的不是瓶頸
Rosalind avatar
By Rosalind
at 2014-09-11T09:13
grep -n '' file | tail 可能也是一樣慢
Susan avatar
By Susan
at 2014-09-13T01:54
wc -l file可以看行數

HackingThursday 固定聚會 (2014-09-04)

Thomas avatar
By Thomas
at 2014-09-01T12:09
通告網址: [http://www.hackingthursday.org/][1] * * * * 時間: 每週四晚上 19:30 至 22:00 ( 熱食供應至 20:00 ) * 地點: 伯朗咖啡 ( 建國店 ) * 地址: 台北市大安區建國南路一段 166 號 2 樓 * 鄰 ...

UBUNTU 14.04安裝時硬碟分割的問題

Hedda avatar
By Hedda
at 2014-09-01T10:41
原本用SPFDISK分割硬碟 100g/100g/2xxg 打算灌win 8/ubuntu 14.04雙系統 win8已安裝在第一個100g 可是後來用ubuntu 14.04安裝時 認不出分割表 顯示出來的分割表不是100g/100g/2xxg 後來用try ubuntu的功能進去ubuntu看 使用s ...

debian on t420s 好多問題...

Puput avatar
By Puput
at 2014-08-31T15:53
各位前輩好,最近剛好因為工作需求,剛好也想趁這個機會好好學習linux, 所以把家裡的t420s整台灌成debian 但碰上了幾個問題,但底子實在有點差,google了幾天也只解開幾個問題, 剩下的實在是找不到,只好上來求助,或是給我相關的關鍵字去search也行 先敘述一下電腦配備 thinkpad ...

XenServer 6.2.0 Hotfix

Caroline avatar
By Caroline
at 2014-08-30T19:50
在未安裝XS62ESP1009 之前 僅依照官網更新方式手動更新 1. CTX139790 – Hotfix XS62ESP1001 - For XenServer 6.2.0 Service Pack 1 andgt; XenCenter update. Not a host side hotfix ...

brix pro 安裝ubuntu14.04 WiFi 無法搜尋

Victoria avatar
By Victoria
at 2014-08-30T11:08
請問我下ifconfig有搜尋求到WiFi 網卡 但無法搜尋到WiFi 請問可以怎麼解決 還是哪裡要設定嗎 有大大知道嗎 -- Sent from my Android - ...