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

Linux 用 cat -A/-T/-E 顯示隱藏字元:Tab、換行、行尾一次看清

編輯:關於 Linux

一般編輯器對不可見字元(Tab、換頁、Ctrl 字元等)顯示不一。cat 提供三個參數精準揭露隱藏字元:-T 顯示 Tab 為 ^I、-E 顯示行尾 $、-A 同時顯示所有不可見字元(含 ^I、$、^L、^@ 等)。本文以實際 printf 產生測試檔,對比 cat、nano、vim 輸出差異,示範三參數實戰效果。

測試檔建立

printf 'testing\012\011\011testing\014\010\012more testing\012\011\000\013\000even more testing\012\011\011\011\012' > /tmp/testing.txt

參數效果對照

指令關鍵輸出片段
cat /tmp/testing.txt僅顯示可見文字,隱藏字元不見
cat -T /tmp/testing.txtTab 顯示為 ^I
cat -E /tmp/testing.txt行尾顯示 $
cat -A /tmp/testing.txt所有不可見字元全顯示(^I、$、^L、^H、^@、^K)

cat -A 是檢查腳本、設定檔隱藏字元導致語法錯誤的最快工具。

Copyright © Windows教程網 All Rights Reserved