More UNIX


Shells


Korn (ksh) Shell

CDPATH=.:..:$HOME
PATH=.:./bin:$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/ucb:\
/usr/local/bin:/usr/bin/X11 
EDITOR=/usr/ucb/vi
ENV=$HOME/.kshrc
EXINIT='set ai nonumber showmatch wrapmargin=72 nowrapscan'
FCEDIT=/usr/ucb/vi
HISTSIZE=32
MAIL=/usr/spool/mail/$USER
PS1="! ${HOST%%.*}> "
SHELL=/usr/bin/ksh
export CDPATH EDITOR ENV EXINIT FCEDIT HISTSIZE HOST MAIL PATH PS1
export SHELL
biff y
tset -I
stty  erase \^? kill \^U intr \^C
umask 0022
alias mail=/usr/ucb/mailx
OSTYPE=`uname`
    

CDPATH Directories searched by cd command.

EDITOR Sets default editor.

ENV Name of script that is executed at startup.

EXINIT Sets options for ex and vi editors.

FCEDIT Editor used by the fc command.

HISTSIZE Number of history commands available (must be set before ksh is started).

PATH Directories searched for any file (command) name. Most important shell variable.

PS1 Primary prompt string; default is $.

SHELL Name of shell environment.

export Pass the value of shell variables, giving global meaning to them.

tset Initializes terminals, setting the TERM variable.

biff y System notifies user of new mail.

stty erase Sets delete character for command line edits.

umask Sets (eliminates) file default access permissions.

alias Allows commands (and options) to be abbreviated.

set -o  trackall


String Operators

${varname:-word} If varname exists and isn't null, return its value; otherwise return word.
${varname:=word} If varname exists and isn't null, return its value; otherwise set it to word and then return its value.
${varname:?message} If varname exists and isn't null, return its value; otherwise print varname: followed by message, and abort the current command or script.
${varname:+word} If varname exists and isn't null, return word; otherwise return null.
${varname#pattern} If the pattern matches the beginning of the variable's value, delete the shortest part that matches and return the rest.
${varname##pattern} If the pattern matches the beginning of the variable's value, delete the longest part that matches and return the rest.
${varname%pattern} If the pattern matches the end of the variable's value, delete the shortest part that matches and return the rest.
${varname%%pattern} If the pattern matches the end of the variable's value, delete the longest part that matches and return the rest.


Job Control


Text Editing: vi

vi filename     If there is no file, vi creates the file.

vi can be in one of the following three modes:

When vi is first loaded, it is in the command mode. This means that all keystrokes entered are interpreted as commands. To return to command mode from input mode, hit <ESCAPE>.

Description Command Code
Move one space to the right Space, l, or right arrow
Move one space to the left h, or left arrow
Move down one line j, or down arrow
Move up one line k , or up arrow
Move one word to the right w, or W
Move one word to the left b, or B
Move to beginning of line 0
Move to end of line $
Move to top of screen H
Move to middle of screen M
Move to bottom of screen L
Save contents to file :w
Quit file :q
Quit vi, saving file only if changes were made :x
Save file and quit vi :wq
Save contents to file and quit vi ZZ
Toggle between uppercase and lowercase ~
Delete back one character X
Delete character under cursor x
Delete line dd
Delete word dw

See the vi notes for more commands and details.

The following commands leave vi in input mode. The table gives the position where the text is inserted.

Description Insert Text
Before cursor i
At beginning of line I
After cursor a
At end of line A
After current line o
Before current line O


Text Editing: emacs


Emacs Compilation


Emacs GNU g++ IDE


XEmacs


I/O Redirection

Devices in UNIX are represented as files:

e.g., /dev/console.

 

UNIX commands receive their input from the standard input (stdin) and send their output to the standard output (stdout), by default these files are the console or terminal.

command name [args] > filename

command name [args] < filename

ls -al | more

ls -al > ls.out

more < ls.out

rm ls.out


UNIX Error Messages

% "How poorly would you rate the UNIX user interface?
Unmatched ".

% rm congressional-ethics
rm: congressional-ethics nonexistent

% ar m God
ar: God does not exist.

% [Where is Jimmy Hoffa?
Missing ].

% ^How did the sex  change^ operation go?
Modifier failed.

% make love
Make: don't know how to make love. Stop.

% got a light?
No match.

%man: why did you get a divorce?
man: Too many arguments.

% ^What is saccharine?
Bad substitute.

$ drink <bottle; opener
bottle: cannot open
opener: not found


Last modified: Mon Nov 3 09:41:41 EST 1997