--------------------------------------------------------------------- DAT2330 - Assignment 3 - Acadaix - 20 marks total - 5% of course mark --------------------------------------------------------------------- Ian D. Allen - idallen@ncf.ca Due: Step 8 (below) must be handed in by 2:00pm Tuesday February 29. Change the permissions on your ACADAIX home directory to 711 before you begin this assignment: chmod 711 $HOME Marks will be deducted for incorrect home directory permissions. Answer the following questions by creating (using the VI text editor) a single text Answer file in your home directory containing all the answers to the questions. You will print this file later. The name of the Answer file is your 9-digit student number followed by five random letters that you choose, exactly as was done in Assignment 2, e.g. a name of the form "040837625wugga". (The five random letters don't have to be the same as the last time.) A sample answer file is in the ACADAIX directory ~alleni/dat2330 under the name "123456789SAMPL". You may look this file to be clear about the submission format. You do not have to copy or edit this file; create your own file in VI using a similar answer format. Unix is a case-sensitive operating system. Command and file names given in this assignment are exact with respect to spelling and upper- and lower-case letters. (See your Linux text, page 21.) Network names for computers are not case-sensitive. ------------------------- Warning! Not all questions ask you to edit command output into the answer file. Do not fill the answer file with un-asked-for output. Marks are deducted for wasted paper. 0. Getting started. Do these two important things first: a) Change the permissions on your ACADAIX home directory to 711 before you begin this assignment: chmod 711 $HOME Marks will be deducted for incorrect home directory permissions. b) At the top of your Answers file, enter the correct absolute pathname to your Answers file. (This is so I can find it in your directory.) Make sure I can read your file! 1. (3 marks) The Unix "grep" command can be used with a pattern to select matching or non-matching lines from a file (or from standard input). a) On ACADAIX, enter the output of the following command line into your answer file: man grep | grep "not match" (Hint: The output is two lines.) Now look at the whole manual page for "grep". Find and read the two small sections of the manual page that contain the two lines output by the above Unix command line. b) Based on your reading, identify the option flag to "grep" that selects "non-matching" lines. Give a Unix command line that will find lines in the password file that *do not contain* the letter "m" anywhere. (Hint: There are 12 lines [non-matching lines] of output on ACADAIX.) c) Based on your reading, identify the special character that is used by "grep" to indicate that a pattern must start at the *beginning* of a line. Give a Unix command line that will find lines in the password file that *do not begin* with the letter "m". (Hint: There are 3037 lines [non-matching lines] of output on ACADAIX. Do not hand in the 3037 lines of output of this command.) 2. (2 marks) This question builds on the last question. Make sure you are clear on the answer to the previous question. a) Give a Unix command line that displays the three lines in the ACADAIX password file that contain the string "000" and that do *not* contain the string "ksh". (The lines displayed contain "000" but not "ksh".) (Hint: Use a simple pipeline that combines two commands; don't try to figure out one single Unix command that does it all.) b) Enter the three lines of output of your command line into the answer file. 3. (3 marks) Looking for keywords in Unix manual pages is a quick way to find out if a command does what you want. Using the method from Question 1a, look for the word "nonprinting" in the man pages for the following commands: tr, more, cat, sort, head a) Which of the above five commands display, or can be made to display, nonprinting characters as visible characters? b) Which of the above five commands' *default* behaviour is to display nonprinting characters as visible characters on your screen? (Warning: if the output of this particular command is going into a pipe or a file, the nonprinting characters are *not* translated and made visible.) c) Which command uses an option flag to turn *on* the display of nonprinting characters as visible characters? (Use this command and its option flag in the next question.) 4. (2 marks) On ACADAIX, the /etc directory contains two file names made up of only non-printing characters. The two names appear last in the directory listing; depending on how you look at the names, the names may appear to be blank. a) Give a Unix command line that shows *only* the two unprintable files in the /etc directory, with a long listing of their permissions, links, owner, size, date modified, etc. The names must be made into visible characters by the command pipeline. b) Enter the two lines of output into the answer file. 5. (4 marks) On ACADAIX there is a command named "resize". When you type "resize" to the shell, the shell has to go looking for the command in order to load and execute it. a) Give the name of the shell environment variable that contains the directories searched by the shell when it goes looking for commands. b) Name all the directories that your shell searches *before* it actually finds the "resize" command on ACADAIX. c) Name the directory in which it finally finds the "resize" command. d) Give the inode number of the "resize" command executable file. 6. (2 marks) You know several ways of extracting parts of text files and creating new files containing just the parts. Sometimes you might choose a text editor; sometimes you might choose one or more Unix commands to do the extraction (especially if the source files were too large to fit easily into a text editor). a) Give a Unix command sequence (one or more Unix command lines) that would put just the top ten and bottom ten lines of the ACADAIX password file into a new file. The resulting file will be 20 lines long. (Do not use VI as any of the commands.) b) Give a Unix command sequence (one or more Unix command lines) that would put just lines 991 through 1000 of the ACADAIX password file into a new file. The resulting file will be 10 lines long. (Do not use VI as any of the commands.) (Hint: Combine two commands in a pipeline to extract the ten lines.) 7. (4 marks) In ACADAIX directory ~alleni/dat2330 is a file named "JCL.txt". Get a copy of this file. Using any of the Unix tools or editors you know, take this file apart and build a new file that has the lines in this file that begin with slashes translated to upper-case. The new file will be exactly the same size as the old one, except that the actual Job Control Language statements (the // lines) in the file will be made into upper-case statements, the way IBM expects them. (Do not make the whole file upper-case.) a) List or describe the actual commands you used to transform the file into the new file. (You will probably need several separate command lines to do the job.) Do not make the whole file upper-case - only change the lines beginning with double slashes: // b) Give the long listing of your new file, showing its permissions, links, owner, size, date, etc. Note: The size of the file should not have changed at all. c) Enter the contents of your transformed file into the answer file. 8. Wrap up. Make sure you do all these steps. a) Go back and make sure you did Step 0. b) Make sure the correct absolute pathname of your Answers file appears at the top of your assignment submission. c) Print your Answers file on 8.5x11" paper, following my Assignment Submission guidelines. Make sure your assignment has an Assignment Submission Label visible from the outside (see my web page). d) Submit your printed assignment to me (or under my office door) before 2:00pm Tuesday February 29. You're done.