加入帶有貓混淆的文件

加入帶有貓混淆的文件

如果我執行以下命令:

$ cat picture.jpg > copy1.jpg

$ cat -v picture.jpg > copy2.jpg

copy1.jpg是 的完美複製品picture.jpg,但copy2.jpg比 的大很多picture.jpg

我認為這是因為copy2.jpg每個 cat 認為的行結尾都被替換為 a ^M,每個的^M大小都比行結尾大。它是否正確?

如果這樣做cat copy2.jpg,我發現沒有^Min的實例copy2.jpg

這裡發生了什麼事?>如果 cat 的輸出可能與其輸入不同,那麼可以依靠 cat 來完美地連接檔案嗎?

答案1

這不僅僅是^M每一個帶有不可列印字元的位元組(無論在當前語言環境中意味著什麼)將被擴展為cat -v.

如果您使用cat連接文件,則需要避免修改輸出的每個選項:-band -n(數字行),-E(標記以 結尾的行$),-s(抑制重複的空行),and -v-T使用可列印的內容顯示不可列印的字符)人物)。

答案2

你的分析對我來說聽起來是正確的。我會用來cat連接文件,因為這是它的主要功能。只需在沒有-v開關或任何與此相關的開關的情況下執行此操作即可。

cat -v ..在該文件上使用基本上已經將其廢棄了。您是否嘗試在圖像檢視器中打開它?我嘗試了你的方法,這正是我的情況。

您也可以使用以下命令查看這方面的證據file

$ file copy*
copy1.png: PNG image data, 1440 x 847, 8-bit/color RGB, non-interlaced
copy2.png: ASCII text, with very long lines

cat的資訊頁面對這個主題有更多的了解:

'-v'
'--show-nonprinting'
     Display control characters except for LFD and TAB using '^'
     notation and precede characters that have the high bit set with
     'M-'.

On systems like MS-DOS that distinguish between text and binary
files, 'cat' normally reads and writes in binary mode.  However, 'cat'
reads in text mode if one of the options '-bensAE' is used or if 'cat'
is reading from standard input and standard input is a terminal.
Similarly, 'cat' writes in text mode if one of the options '-bensAE' is
used or if standard output is a terminal.

那麼 ^M 在哪裡?

如果您打開copy2.jpg文件,vim您會發現其中散佈著它們,例如:

                  SS#1

相關內容