COMP 2673 - Lab1 In-lab Assignment Goals: log on, change password, create directories, list files, change directories, print current directory, copy files, move files (use mv to move file to a new directory, and to rename) edit a file with vi: open program with a new file or with an existing file move around using h,j, k, l, w, b, 0, $. (or arrow keys) insert mode vs. command mode (i to enter, esc to exit) deleting text with #dl, dd / and ? save file quit with/without saving vi commands: vi editor has 2 modes: the insert mode and the command mode. To insert text you need to be in the insert mode (whatever you type in this mode gets inserted in the file), whereas you need to be in the command mode to move around, delete text, search text, save file, quit vi, etc. To change from command mode to insert mode, type i. To change from insert mode to command mode, press . The following commands work only in command mode: 1. move around by tying using h(left), j(down), k(up), l(right). You may also use the arrow keys for the same (but arrow keys may not work if you are working remotely through telnet). 2. To move faster use w(next word), b(previous word), 0(begin of line), $(end of line). 3. To delete text type #x, where # is the number of characters to be deleted. To delete complete line, type dd. 4. To search for the word 'foo' in downward direction type /foo. To find next occourance of the same word type n. To search for the word 'foo' in upward direction type ?foo. To find next occourance of the same word type n. 5. while in command mode, type... To save file type :w To save file and quit vi type :wq To quit vi without saving type :q! Steps: 1. Log on to one of the machines in the Sun Lab. 2. To open a terminal, right click, select Tools, then select Terminal. 3. Change your password by typing 'passwd' at the command prompt on the terminal and then typing the old and new password when prompted. 4. Create directory (folder) 'IntroToCS3' by typing 'mkdir IntroToCS3'. 5. Change the current directory to 'IntroToCS3' by typing 'cd IntroToCS3'. 6. You can now check the current directory by typing 'pwd' (which happens to be the acronym for present working directory). 7. Copy the file 'lab1_original.cpp' by typing 'cp ~sarora/IntroToCS3/lab1_original.cpp .' (where . stands for the current directory). 8. List files in the current directory by typing 'ls' to make sure that 'lab1_original.cpp' now exists in your current directory. 9. Create directory 'lab1' in the current directory by typing 'mkdir lab1'. 10. Move the file 'lab1_original.cpp' to the directory lab1 by typing 'mv lab1_original.cpp lab1'. 11. List files in the current directory by typing 'ls' to make sure that 'lab1_original.cpp' now does not exist in your current directory. 12. List files in the subdirectory by typing 'ls lab1' to make sure that 'lab1_original.cpp' exists in the lab1 subdirectory. 13. Change the current directory to 'lab1' by typing 'cd lab1'. 14. You can now check the current directory by typing 'pwd'. 15. List files in the current directory by typing 'ls' to make sure that 'lab1_original.cpp' exists in your current directory. 16. To personalise the file name, rename the file 'lab1_original.cpp' to 'lab1_yourname.cpp' where yourname is "Your Name". You can do this by typing 'mv lab1_original.cpp lab1_yourname.cpp'. 17. Open the file in vi editor by typing 'vi lab1_yourname.cpp'. 18. Edit the file with vi editor using vi commands above: a. Change the name of function from dipslay() to display(). b. Replace all occourances of 'z' with ')'. c. Add a comment at the beginning of file: '// modified by "Your Name"'. 19. Save the file and email OR turn-in a printout to your TA.