Section 3.7. Special Characters


[Page 47 (continued)]

3.7. Special Characters

Some characters are interpreted specially when typed in a Linux terminal window. These characters are sometimes called metacharacters, and may be listed by using the stty utility with the -a (all) option. The stty utility is discussed fully at the end of this chapter. Here's an example:

$ stty -a      ...obtain a list of terminal metacharacters speed 38400 baud; rows 35; columns 80; line = 233; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0; -parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts -ignbrk brkint ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany imaxbel opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke $ _ 


The ^ in front of each letter means that the Control key must be pressed at the same time as the letter. The default meaning of each option is shown in Figure 3-4.


[Page 48]

Figure 3-4. stty options.

Option

Meaning

erase

Backspace one character.

kill

Erase all of the current line.

werase

Erase the last word.

rprnt

Reprint the line.

flush

Ignore any pending input and reprint the line.

lnext

Don't treat the next character specially.

susp

Suspend the process for a future awakening.

intr

Terminate (interrupt) the foreground job with no core dump.

quit

Terminate the foreground job and generate a core dump.

stop

Stop/restart terminal output.

eof

End-of-input.


Some of these characters won't mean much to you until you read some more chapters of this book, but there are a few worth mentioning immediately: Control-C, Control-S, Control-Q, and Control-D.

3.7.1. Terminating a Process: Control-C

Often when you run a program you wish to stop it before it's finished. The standard way to do this in Linux is to press the keyboard sequence Control-C. Although there are a few programs that are immune to this form of process termination, most processes are immediately killed, and your shell prompt is returned. Here's an example:

$ man chmod CHMOD(1)             User Commands                 CHMOD(1) NAME        chmod - change file access permissions SYNOPSIS ^C       ...terminate the job and go back to the shell. $ _ 


3.7.2. End-of-Input: Control-D

Many utilities may take their input from either a file or the keyboard. If you instruct a utility to do the latter, you must tell the utility when the input from the keyboard is finished. To do this, type a Control-D on a line of its own after the last line of input. Control-D means "end-of-input." For example, the mail utility allows you to send mail from the keyboard to a named user:


[Page 49]

$ mail tim         ...send mail to my friend tim. Hi Tim,            ...input is entered from the keyboard.  I hope you get this piece of mail. How about building a country one of these days? - with best wishes from Graham ^D          ...tell the terminal that there's no more input. $ _ 


The mail utility is fully described later in this chapter.




Linux for Programmers and Users
Linux for Programmers and Users
ISBN: 0131857487
EAN: 2147483647
Year: 2007
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net