Presentation is loading. Please wait.

Presentation is loading. Please wait.

The UNIX development environment CS 400/600 – Data Structures.

Similar presentations


Presentation on theme: "The UNIX development environment CS 400/600 – Data Structures."— Presentation transcript:

1 The UNIX development environment CS 400/600 – Data Structures

2 ADTs and SimpleList2 Basic UNIX commands  The directory tree pwd – Print working directory ls – List contents cd – change directory  Relative path: dir/dir/dir  Absolute path : /dir/dir/dir Special directory names: . = current directory .. = parent directory  ~ = my home directory  ~fred = fred’s home directory

3 ADTs and SimpleList3 Working with files  More directory commands mkdir – make directory rmdir – remove directory (must be empty)  File commands cp – copy a file mv – move or rename touch – create a file or update the timestamp rm – remove a file  rm -r – remove an entire directory (BE CAREFUL!)

4 ADTs and SimpleList4 More commands  Files ls -l – show file details chmod – change permissions  user, group, other  rwx,rwx,rwx  chmod 640 = user: rw, group: r, other: none  chmod g+w = add group write permission

5 ADTs and SimpleList5 Running Programs and Redirection  Safest:./program  Redirection program > filename (cout  file) program < filename (cin  file) program file2 program1 | program2 (output of program1 becomes cin for program2)  Examples: ls > file, more < file, ls | more

6 ADTs and SimpleList6 The VI text editor  VI  Two modes: command and editing  Use to get to command mode  Be careful with CAPS LOCK  Basic commands i = insert text (go to editing mode) :w = write changes (save) :wq = save and exit (or ZZ) :q! = exit without saving

7 ADTs and SimpleList7 Cursor Movement  Switch to command mode Arrow keys or (k , j , h , l  ) to move around ^f / ^b = forward/back 1 screenfull ^d / ^u = down/up ½ screenful H / L = move cursor to top / bottom of screen 0 (zero) / $ = move cursor to start / end of line G = go to last line of the file #G = go to line number # of the file (useful for debugging)

8 ADTs and SimpleList8 Text Operations  x = delete one character  D = delete to end of line  dd = delete entire line  dw = delete word  r = replace one character  R = replace until escape is pressed  i = insert characters (edit mode)  a = append characters (edit mode)  o = “open” a new blank line (edit mode)  J = join this line with the next one

9 ADTs and SimpleList9 Tips  # followed by a command is very handy 29dd = delete 29 lines 34G = go to line 34 17  = move 17 characters to the right 5dw = delete 5 words  Period (.) in command mode repeats last command Can be combined with the above  yy = “yank” (copy) one line, p = paste Paste works after delete commands (dd, dw,etc.) too

10 ADTs and SimpleList10 Lnode Slist Compiling Lnode.h Slist.h Slist.cpp Slist_main.cpp g++ -c Slist.cpp g++ -c Slist_main.cpp g++ -o slist Slist.o Slist_main.o

11 ADTs and SimpleList11 Dependency Tree slist Slist_main.o Slist_main.cppLnode.hSlist.h Slist.o Slist.cppSlist.hLnode.h

12 ADTs and SimpleList12 Makefile # M. Raymer -- 9/2004 # CS 400/600 -- Data Structures and Software Design # ------------------------------------------------------------- # Use the following CFLAGS for debugging CFLAGS= -g -ggdb -DUNIX # Use these CFLAGS for optimized, non-debugging code #CFLAGS= -O -DUNIX CC= g++ slist: Slist.o Slist_main.o $(CC) $(CFLAGS) -o slist Slist.o Slist_main.o Slist.o: Slist.h Slist.cpp Lnode.h $(CC) $(CFLAGS) -c Slist.cpp Slist_main.o: Slist_main.cpp Slist.h Lnode.h $(CC) $(CFLAGS) -c Slist_main.cpp clean: rm -f *.o slist Must be a tab character!


Download ppt "The UNIX development environment CS 400/600 – Data Structures."

Similar presentations


Ads by Google