Command-Line Prompt

Most of bioinformatics is done with command-line software, so you should take some time to learn to use the shell effectively.

This is a command line prompt:

bush202>

This is another:

(~) 51%

This is another:

lstein@bush202 1:12PM>

What you get depends on how the system administrator has customized your login. You can customize yourself when you know how.

The prompt tells you the shell is ready to accept a command. When a long-running command is going, the prompt will not reappear until the system is ready to deal with your next request.

Issuing Commands

Type in a command and press the <Enter> key. If the command has output, it will appear on the screen. Example:

(~) 53% ls -F
GNUstep/                 cool_elegans.movies.txt  man/
INBOX                    docs/                    mtv/
INBOX~                   etc/                     nsmail/
Mail@                    games/                   pcod/
News/                    get_this_book.txt        projects/
axhome/                  jcod/                    public_html/
bin/                     lib/                     src/
build/                   linux/                   tmp/
ccod/
(~) 54%

The command here is ls -F, which produces a listing of files and directories in the current directory (more on which later). After its output, the command prompt appears agin.

Some commands, such as netscape, launch a graphical program. In this case, the command prompt won't reappear until the program finishes. This is annoying behavior, so a better way to run such programs is to run them in the background. The easiest way to do this is to add an ampersand (&) to the end of the command like this:

(~) 54% netscape&
(~) 55% 

Command Line Editing

Most shells offer command line entering. Up until the comment you press <Enter>, you can go back over the command line and edit it using the keyboard. Here are the most useful keystrokes:

Backspace
Delete the previous character and back up one.
Left arrow, right arrow
Move the text insertion point (cursor) one character to the left or right.
control-A (^A)
Move the cursor to the beginning of the line. Mnemonic: A is first letter of alphabet
control-E (^E)
Move the cursor to the end of the line. Mnemonic: <E> for the End (^Z was already taken for something else).
control-D (^D)
Delete the character currently under the cursor. D=Delete.
control-K (^K)
Delete the entire line from the cursor to the end. K=Kill. The line isn't actually deleted, but put into a temporary holding place called the "kill buffer".
control-Y (^Y)
Paste the contents of the kill buffer onto the command line starting at the cursor. Y=Yank.
Up arrow, down arrow
Move up and down in the command history. This lets you reissue previous commands, possibly after modifying them.

There are also some useful shell commands you can issue:

history
Show all the commands that you have issued recently, nicely numbered.
!<number>
Reissue an old command, based on its number (which you can get from history)
!!
Reissue the immediate previous command.
!<partial command string>
Reissue the previous command that began with the indicated letters. For example !l would reissue the ls -F command from the earlier example.

tcsh offers automatic command completion and spelling correction. If you type part of a command and then the tab key, it will prompt you with all the possible completions of the command. For example:

(~) 51% fd<tab> 
(~) 51% fd
fd2ps    fdesign  fdformat fdlist   fdmount  fdmountd fdrawcmd fdumount
(~) 51% 

If you hit tab after typing a command, but before pressing <Enter>, tcsh will prompt you with a list of file names. This is because many commands operate on files.

Type a few letters and then Alt-p to make tcsh search backwards for a command you previously issued that starts with those letters.

Wildcards

You can use wildcards when referring to files. "*" refers to zero or more characters. "?" refers to any single character. For example, to list all files with the extension ".txt", run ls with the pattern "*.txt":

(~) 56% ls -F *.txt
final_exam_questions.txt  genomics_problem.txt
genebridge.txt		  mapping_run.txt

There are several more advanced types of wildcard patterns which you can read about in the tcsh manual page. For example, you can refer to files beginning with the characters "f" or "g" and ending with ".txt" this way:

(~) 57% ls -F [f-g]*.txt
final_exam_questions.txt  genebridge.txt	    genomics_problem.txt

Logging Out

When you've had enough fun with the shell, log out with logout or exit. No, not bye, nor quit, nor even logoff work. This will close the terminal window.
<< Previous
Contents >> Next >>


Lincoln D. Stein, lstein@cshl.org
Cold Spring Harbor Laboratory
Last modified: Thu Oct 9 19:39:06 EDT 2003