The Editor: Insert Mode Esc
The Editor: Insert Mode Esc
The
vi editor
esc
All keys except esc insert text.
Move mode c w cc / search text rtn i o ? search text rtn a R I C n ,N Re-search O n cc . Repeat previous command u Undo n y y Copy n lines to buffer x X dw p , P Paste below or above D dd J Join lines w W b Ctrl-f Ctrl-g show line number B e E Ctrl-b Z Z same as : w q rtn : Go to command mode nG find Command mode esc cancels rtn
modify
move
C. Bystroff 2003
delete
UNIX basics
To get a command line interface on Irix, use "Open UNIX Shell" from the Toolbox. Commands you should know: ls == list files ( use ls -l for long format) grep string file == find a character string within a file. mkdir directory == make a new directory (use rmdir to remove it) cd == change your working directory (use cd .. to go up one directory, cd ../.. to go up two directories.) pwd == print working directory more file == view a file page by page vi file == edit a file. (see vi page)
UNIX basics
rm file == delete file mv file directory/newname == rename (move) file Redirecting input/output: sort < inputfile > outputfile Running a command in the background: sort < inputfile > outputfile & (or use ctrl-z) Piping one command to another: sort inputfile | more Setting the X-windows display: on the local machine: xhost + on the remote machine: setenv DISPLAY localmachine.rpi.edu Getting more information on UNIX commands: man command == read the manual
IP addresses have the form A.B.C.D where A, B, C and D are either integers (0-255) or names (such as bioinf45.bio.rpi.edu). To transfer files between machines: ftp IP_address , then login using username and password FTP commands get file, put file == download or upload mput, mget == download, upload multiple files cd directory == change directory remotely ls == list files remotely bin, asc == set file transfer to binary, ascii bye == disconnect
Pseudocode
constant variable statement assignment
real (1.23), integer (4), character("4"), or Boolean a name, assignable to a constant. {<assignment>|<conditional statement>|<loop>} [<statement>] a <-- b or a = b, where a is a variable and b is a variable. constant, or a formula using binary and unitary operators. [NOT] a <boolean operator> b [{AND | OR} <condition> Evaluates to true (1) or false (0). if (<boolean>) then <statement> [else <statement>] endif {<for loop>|<while loop>} for ( i from a to b ) do <statement> enddo while (<condition>) do <statement> enddo a[i] A numbered set of variables. a[i,j] Range in i: a[i..k,j] = (a[i,j].a[i+1,j],...,a[k,j]) + - * / ^ % (add,subtract,multiply,divide,modulus) sqrt(), log(), exp(), sin(), cos(), tan(), len(),etc. (builtin functions) > < == (greater than, less than, equal to) read file <variables> , assigns variables from file. write file <variables>, output to file. (Use * for standard input/output) return x When used in a function, sets the returned value of the function to x. a <-- F(x,y) { <statements> return x }
condition conditional statement loop for loop while loop array 2D array binary operators unitary operators Boolean operators read write return function
A Pseudocode program for calculating the distance between two points, a and b:
a[1..3] = (1.1, 2.2, 3.3) b[1..3] = (4.4, 5.5, 6.6) sum = 0 for i from 1 to 3 do x <-- (a[i] - b[i])^2 sum <-- sum + x enddo x = sqrt(sum) write *, "The distance is ", x
A Pseudocode program using a function.Converts a character array (string) to an integer array: // 1="A", 2="C",3="G",4="T" base[1..4] = ("A","C","G","T") read *, sequence for i from 1 to len(sequence) do s[i] = getbase(sequence[i]) enddo write *, "The sequence is ", sequence[1..len(sequence)] write *, "The integer sequence is ", s[1..len(sequence)] getbase(a) { i <-- 1 while (NOT base[i] == a) do i <-- i + 1 if (i > 4) return 0 enddo return i }