LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-19-2007, 05:05 PM   #1
Mahonri
Member
 
Registered: May 2007
Location: Austin, Texas, USA
Distribution: Debian Etch
Posts: 34

Rep: Reputation: 15
How do I generate ASCII control characters from they keyboard?


I'm trying to figure an easy way to generate certain control characters such as NUL and EOF from the keyboard for testing purposes.

Does anyone know how to do it?

This is possible on Windows/DOS by turning the Num Lock key on, and then holding down the ALT key while you enter the numeric code from the keypad.

I'm assuming there is a similar mechanism with Linux.
 
Old 09-20-2007, 05:45 AM   #2
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 61
Have you tried just using the appropriate control character? (I can't think of an easy way to test this, or I would have.) For example, Ctl-@ is NUL, Ctrl-\ is FS, etc.

Also note that you can send such characters to STDOUT (or redirect or pipe them) using echo:

echo -en "\nnn"

will send the character whose octal value is nnn, i.e.

echo -en "\033"

sends an escape.

BTW, I don't think there is an ASCII character designated EOF, although IIRC, MS-DOS used Ctl-Z for this purpose on text files.

EDIT: I just found out how to test just using the Ctrl key and it does indeed work except for the characters the shell wants to interpret such as Ctrl-C.

Last edited by blackhole54; 09-20-2007 at 06:12 AM. Reason: added needed quotation marks
 
Old 09-20-2007, 08:32 AM   #3
Mahonri
Member
 
Registered: May 2007
Location: Austin, Texas, USA
Distribution: Debian Etch
Posts: 34

Original Poster
Rep: Reputation: 15
Thanks for the tips blackhole. I was able to do most of what I wanted by just using VI/VIM to edit text files. Apparently from insert mode, you can do ctrl-v, followed by ctrl-? to insert a control character within a text file. The only one that did not quite work for me was the EOF character, which would have truncated my file.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to insert characters by ascii code? J_Szucs Linux - General 14 06-17-2017 12:33 PM
typing high-ascii characters gerrym Linux - Newbie 1 08-12-2004 12:38 AM
Extended ASCII characters in UNIX MatSzor Programming 5 05-15-2004 09:57 PM
ascii characters lakshman Linux - General 1 03-14-2003 11:28 AM
Deleting non ASCII characters Thinkgeekness Linux - Networking 4 03-04-2003 01:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration