Chinaunix首页 | 论坛 | 博客
  • 博客访问: 18393
  • 博文数量: 3
  • 博客积分: 496
  • 博客等级: 一等列兵
  • 技术积分: 40
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-04 12:31
文章分类

全部博文(3)

文章存档

2010年(3)

最近访客

分类:

2010-08-06 21:51:25

by Marvin Crippen, Adaptive Technology Assistant
What is a shell?A shell is a command language interpreter. It translates your commands so that Unix can understand them. There are a variety of shells and some have more bells and whistles than others. The 3 most common shells are sh (the original, also known as the Bourne shell), csh (Command SHell) and tcsh (an enhanced version of csh). Other shells include bash (Bourne-Again SHell), ksh (Korn SHell) and zsh. The default shell (what you use unless you select something different) on DO-IT's Hawking computer is csh. cshCsh features include, but are not limited to, a history mechanism and job control facilities.

History Mechanism

Try typing history at your host system (e.g., hawking) prompt. Csh typically prints out a numbered list of the last 20-30 commands you've typed. To run any of the commands again type !NN where NN is the history number of the previous command. You can also type ! and the first few letters of the command. If you type !ls csh runs the last command that started with ls. If you wish to save more than 20-30 commands in the history list type set history=X where X is the number of items on the history list. Don't make the number too high or csh will run out of memory. To make this change permanent put the set history=X line in your .cshrc (the name of this file is .cshrc no matter what shell you're using) file. It is also possible to do history substitution, running a command from the history list with a few changes to it. For more details on this see the History Substitutions section of the csh manual page (man csh ).

Job Control Features

Let's say you're sending e-mail to someone telling them about the ls command and you want to include a portion of the man page, such as what the -l switch does. You could

  1. postpone the message,
  2. quit Pine (or other electronic mail software you're using),
  3. look up the manual page,
  4. cut out the relevant parts,
  5. quit the man page,
  6. start Pine again,
  7. restart the postponed message and
  8. paste the relevant text.
You would have to go through this process each time you want to copy something from the man page. Or using the job control features of csh you could
  1. suspend Pine (assuming the enable-suspend feature of Pine is on) by typing -Z,
  2. look up the manual page,
  3. cut out the relevant parts,
  4. suspend the man page by typing -Z,
  5. go back to composing the message by typing %- and
  6. paste the relevant text.
If you wanted to copy another section of the ls man page you would type -Z, %- to get to the man page and -Z , %- to get back to Pine.

Typing jobs at your host system prompt displays a numbered list of all suspended jobs. The current job is marked with a plus sign (+) and the previous job is marked with a minus sign (-). To enter a suspended job you can type %+ for the current job, %- for the previous job and %X where X is the number of the job from the jobs command. tcshTcsh is an enhanced version of the csh. It behaves exactly like csh but includes some additional utilities such as command line editing and filename/command completion. Tcsh is a great shell for those who are slow typists and/or have trouble remembering Unix commands.

Command Line Editing

Command line editing allows you to access any command from the history list and make edits to it before execution. You can use the up and down arrows keys, or -N (Next) and -P (Previous) to cycle through the history list. You can use the right and left arrow keys, or -B (Backward) and -F (Forward) to position the cursor within a command. Typing inserts text into the command, the Backspace and Delete keys can be used to erase characters from the command. Other useful keys are -A to move to the beginning of a line, -E to move to the end of line, and -C to cancel an edit.

File Name and Command Completion

You can use the ; key to cut down on the amount of typing you do. When you press the key tcsh will try to complete either a filename or a command. If the filename is unique tcsh will type the rest of it. If the filename isn't unique tcsh will complete as much as possible and beep. For example, let's say you have a directory called example/testing/ and in that directory you have a couple of text files called file1.txt and file2.txt and a command called reallysuperlongcommand. If you want to run the command in that directory you type ex tes real and tcsh fills in example/testing/reallysuperlongcommand. If you want to look at file2.txt you type more ex tes fi and tcsh writes more example/testing/file. Since file2.txt is not a unique file name tcsh beeps at this point and finishes the line with 2.txt once you press 2 .

How to change your shell

To change what shell you use type chsh(CHange SHell) and type in the location of the new shell when prompted. The location of tcsh on the Hawking computer is /usr/local/bin/tcsh. The new shell will not take effect until the next time you log on and will stay in effect until you change it again.

For more information about csh and tcsh, consult the appropriate man page (man [shell name]) or send me e-mail at mcrip@u.washington.edu.

阅读(1366) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:幼稚还是成熟?判断起来其实很容易

给主人留下些什么吧!~~