This page looks plain and unstyled because you're using a non-standard compliant browser. To see it in its best form, please upgrade to a browser that supports web standards. It's free and painless.

My life,my experience...
   喜歡一種 自由自在 無拘無束的感覺
Album | Blog | Comment | Profile | Control Panel
fvalinux | 13 August,2007 8:12
Bookmark: HemiDemi MyShare Baidu Google Bookmarks Yahoo! My Web Del.icio.us Digg technorati furl Bookmark to:YouPush Bookmark to:你推我報

之前有時會突然想到這個問題,以前在dos下你可以用copy con filename.txt
來用鍵盤輸入ASCII字元(包含unprintable)到一個檔案上,可以不需要使用任何
文字編輯工具(像PE2或edit)
那麼在Linux下有辦法嗎??
上網查了一下(keyword: linux copy con),發現可以用cat 這個指令來達成.
先大概講解在dos下的用法
在dos的命令提示字元下輸入copy con filename.txt,
中間參數con為dos的設備名稱,con是控制台,指的是鍵盤
另外還有aux為另外一台終端機,nul就像是個黑洞(e.g. /dev/null in unix)
當輸入完這串指令後,就可以開始新增或刪除字元
你可以輸入任意字母或數字另外還可以輸入ASCII的字元
像65是大寫英文字母A,97是小寫a
輸入方法為:先按著alt鍵不放,再打入3碼ASCII以十進位的數,最後再放開alt鍵.
另用這方法你就可以用ASCII為8的這個backspace功能來刪除字元,當然你也可以直接
按鍵盤上的backspace,
這方法我覺得在你想測試某些鍵盤無法直接輸入的ASCII字元還滿方便的.
最後按Ctrl+z鍵或F6鍵可以存檔並離開.
--
現在換到linux了
在linux下你可以輸入
cat > filename
或者以附加的方式
cat >> existed-file
的方式來輸入任意字元,而且還可以像dos裡面輸入任意的ASCII字元
想離開時輸入ctrl+D可以存檔並且離開
或是ctrl+C放棄編輯&離開.
小心按成ctrl+Z會把process丟到背景去呀...


補 充:想在linux下編修十六進位檔也可執行hexedit


Comment

Uuencode

http://zh.wikipedia.org/wiki/Uuencode
這玩意可將二進位檔編碼成printable ASCII
e.g.
$uuencode binary_file file-name > uuencode_binary_file
這工具的用法解釋如下
將binary_file這個檔內容編碼,編碼內容的檔案名稱是file-name,也就是用uudecode解碼後產出的檔案的名稱,
然後將整個編碼內容存成一個叫
uuencode_binary_file
的檔案。
(可將參數2視為編碼內容第一行的第三欄位值)
或者是
$cat binary_file | uuencode file-name > uuencode_binary_file
利用預設的standard input來收資料也可.
不過它似乎不吃以<為導向的檔案@@
最後收到的人再打
$uudecode uuencode_binary_file
就會有一個名稱為file-name的檔自動產生.

Fva...  |  15/10/2007 00:29:56

Introduction to Control Character

http://en.wikipedia.org/wiki/Control_character

Fva...  |  31/08/2008 15:14:50

Trackback

Comment Permissions: Allow commenting

Leave Comment

*Name/Nickname
E-mail
Personal Website
Comment Title
*Comment
* Private Comment