Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

CentOS split 指令大檔案分割與日誌分析實戰

編輯:關於 Linux

split 可將大檔案(如超大日誌)切割成小檔,便於下載、分析。常用參數:

  • -a:後綴長度(預設 2)
  • -b:每檔大小(支援 K、M、G)
  • -d:數字後綴(預設字母)
  • -l:每檔行數

範例:將 100MB 日誌切成 10MB 段,數字後綴

split -a 2 -d -b 10m /var/lib/mysql/general.log nowamagic

產生 nowamagic00 ~ nowamagic09,最後一檔可能小於 10MB。配合 tail -f nowamagic09 即時看最新日誌。

合併檔案:cat nowamagic* > general.log。適用於日誌輪轉未生效、單一巨大檔案難以處理的場景。

Copyright © Windows教程網 All Rights Reserved