UNIX Commands – list contents of a directory – display current directory – change to directory (cd ) – copy (cp from_file to_file) – move file (mv from_file to_file) – delete file (rm test1) directory (mkdir test) – remove directory (rmdir test) man – for given command (man cp) – display contents of file – display contents of file with page breaks (next page with Space key) – display of file – display end of file – search for pattern in file (grep “pattern“ test1) – edit file (more on this later) – count number of lines, words, characters in a file (wc -l file.txt) – cut out parts of file (cut -f 2 -d : file.txt) – report disk usage (du -h) – report file systems and their usage (df -h) – change permissions of a file (chmod a+r file.txt) – create a to a file (ln -s ~/bin/prog.exe prog1.exe)

Wildcards: * - matches any number of letters incl. none ? - matches any single character [] - encloses set of characters that can match the single given position - used within [] denotes range of characters ~ - followed by user name = home directory (~mcuma)

Command redirection: > redirect to a new file (cat test1 > test3) >> - append to a (new or existing) file (cat test2 >> test3) | - pipe – redirect command output to another command Vi basic reference i – insert I – insert start of line a – append A – append at end of line o – enter insert mode on a new line r – replace single letter R – replace mode x – delete letter – delete line D – delete from cursor to end of line u – undo

G – move to end of file #G – move to line # ^ - move to start of line $ - move to end of line ctrl-f – move page forward ctrl-b – move page back

: – save current file :w filename – save file to new file :q – quit vi :wq – save and quit :q! - quit without saving :w! - force save :n filename – open another file

/pattern – search forward for pattern ? - search backward for pattern; subsequent entry of / or ? searches for next occurence of pattern

:s/old_text/new_text – replace next occurence on current line :s/old_text/new_text/g – replace all occurence on current line :%s/old_text/new_text/g – replace all occurences in the whole file Scripting

Loops foreach VAR ($VARLIST) … end while (condition) … end break – break out of the loop continue – skip to next loop iteration

Conditions if (condition) then … else … endif switch (string) case pattern1: … breaksw default: commands... breaksw endsw

Conditional expressions

==, !=, >, < ,&& ,|| - equal, not equal, larger, smaller than, and, or - like in C language !($?var) – true if variable does not exist =~ - if the right hand side matches a pattern, (i.e., similar to filename matching, with asterisks and question marks.) the condition is true. !~ - if the right hand side doesn't match a pattern, the condition is true. -d $var - true if the file is a directory. -e $var - true if the file exists. -f $var - true if the file is a file. (I.e., not a directory) -o $var - true if the file is owned by the user. -r $var - true if the user has read access. -w $var - true if the user has access. -x $var - true if the user has execute access. -z $var - true if the file is zero-length.

Shell variables variables are denoted with $ - $VAR defined by set – set VAR=(1 2 3 4) numbers defined by @ - @i = 1 conversion of string to number with - @i = `expr $number + 0`