Download CS 2204 Lab Assignment 2 - Customizing Shell and Manipulating Text Files using Vim and more Lab Reports Computer Science in PDF only on Docsity! CS 2204 Lab Assignment 2 Fall 2008 Preliminaries: 1. Sign the attendance sheet 2. The instructor will distribute the hard copy of the assignment in the class. 3. In this assignment, we will look at customizing your session and manipulating text files using vim 4. You may refer to http://staff.washington.edu/rells/R110/ for more information about Vi. Total Points: 27 pt Validation: Submit the solutions to the instructor when you have finished all the exercises. 1. alias is used to substitute a command with another command. Use the man pages for more information. a. (1 pt) Use this command, so that every time you execute ls, ls ‐al is actually the one that is executed. Write down what you did. b. (1 pt) Again use alias, so that when you rm with a file, it is not deleted but moved to the directory /tmp. Hint: It is in your lecture 3 notes. Write down what you did. c. (2 pt) Now logout of the shell by typing “exit”. Then log in again. Check if the aliases of (a)and (b) still work. Well, it shouldn’t as aliases are lost when the shell session is closed. How do we make this permanent? For this we put the alias commands in the ~/.bashrc file. This is the bash configuration file that is executed when the shell is invoked. Check if your aliases are retained from session to session. 2. Preliminary: A file called unix.txt, containing a part of the Wikipedia entry for UNIX, has been created and uploaded at http:// http://people.cs.vt.edu/~jkorah/lab3/unix.txt . Use the wget command to download it into your local directory. Look into the man pages for wget for more information. Open the file in vi editor and do the following exercises. For each question, write down the vi commands, keys etc used. Do not use arrow keys. For each question come up with the shortest or most efficient way a. (1 pt) Go to line 20. How did you verify? b. (1 pt) Move to the end of the line using one key stroke c. (1pt) Move 5 lines up, then 10 characters to the right d. (1pt) Search for the word “Timeline”. e. (1pt) The line next to it is a repetition, delete the repetition f. (1pt) Scroll up by a page g. (2pt) Search for the word “unix”. You didn’t find any though there are a whole lot of “Unix”. So the search is case sensitive. How do you make the search case insensitive? Hint: change the set options Try your search again. h. (2pt) Find the number of lines in the file without counting them i. (4pt)In this question, we are going to substitute “Unix” with Linux. But before doing this, we will store line 10 which contains two instances of “Unix” in the vi buffer a. Now, substitute all instances of “Unix” (case sensitive) with “Linux” j. (1pt) What was the Unix project called in the 1970s at AT&T Bell labs? I know, the file is long. So search for Multics, the answer should be in that region of the file k. (1pt) Delete lines from 5 to 10 (inclusive)