自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Linux終端:用cat命令查看不可見字符

系統(tǒng) Linux
時常,某個程序或軟件并沒有語法錯誤,并且你檢查它的相關(guān)內(nèi)容也確實沒有發(fā)現(xiàn)問題。這是因為你用普通文本編輯器軟件來查看的時候,有許多字符沒有顯示出來,但在終端使用cat命令可以很容易地檢測出是否存在這些字符。

時常,某個程序或軟件并沒有語法錯誤,并且你檢查它的相關(guān)內(nèi)容也確實沒有發(fā)現(xiàn)問題。這是因為你用普通文本編輯器軟件來查看的時候,有許多字符沒有顯示出來,但在終端使用cat命令可以很容易地檢測出是否存在這些字符。

首先,我們創(chuàng)建一個簡單的文本文件,寫入一些特殊字符。打開終端,運行命令:

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

現(xiàn)在用不同的編輯器軟件打開,顯示的結(jié)果會不同。用簡單的cat打開將顯示:

  1. $ cat /tmp/testing.txt  
  2. testing 
  3.         testing 
  4.  
  5. more testing 
  6.  
  7. even more testing 

如果用nano或者vim打開,將會看到:

  1. testing 
  2.             testing^L^H 
  3.  
  4. more testing 
  5.     ^@^K^@even more testing 

現(xiàn)在我們給cat加上一些選項參數(shù),以便能顯示出特殊字符來。

用cat -T命令來顯示TAB鍵的字符^I

  1. cat -T /tmp/testing.txt 
  2. testing 
  3. ^I^Itesting 
  4.  
  5. more testing 
  6. ^I 
  7.   even more testing 
  8. ^I^I^I 

用cat -E命令來顯示行尾的結(jié)束字符$

  1. $ cat -E /tmp/testing.txt 
  2. testing$ 
  3.         testing 
  4.   $ 
  5. more testing$ 
  6.  
  7. even more testing$ 
  8.             $ 

用簡單的cat -A命令就可以顯示所有不可見的字符:

  1. $ cat -A /tmp/testing.txt 
  2. testing$ 
  3. ^I^Itesting^L^H$ 
  4. more testing$ 
  5. ^I^@^K^@even more testing$ 
  6. ^I^I^I$ 
責任編輯:奔跑的冰淇淋 來源: Linux中國
相關(guān)推薦

2010-01-05 16:49:34

2010-06-24 14:32:07

Linux Cat命令

2010-01-15 19:37:36

Linux命令

2010-07-08 13:38:42

SQL Server不

2010-06-24 11:16:17

Linux Cat命令詳解

2010-06-24 14:08:25

Linux Cat命令

2023-07-23 19:26:18

Linuxcat 命令

2013-12-10 10:41:28

Linux終端smem內(nèi)存

2020-11-30 13:12:04

Linux文本命令

2022-06-17 16:27:14

Linux終端互聯(lián)網(wǎng)

2010-06-24 14:12:20

Linux Cat命令

2015-02-10 11:15:46

Android 5.1Google

2015-02-05 09:29:25

Android 5.1

2009-12-16 14:10:42

Linux終端命令

2022-08-10 13:12:04

Linuxcat命令

2011-04-01 14:43:14

SQL Server不可見字符

2009-12-16 09:40:38

Linux終端Linux命令

2011-04-21 13:01:15

visibilitydisplay

2013-01-29 14:08:58

UbuntuUbuntu手機Ubuntu手機操作系

2010-06-24 14:38:48

Linux Cat命令
點贊
收藏

51CTO技術(shù)棧公眾號