Programming > EXAM > Arizona State University - IFT 383 Final Exam. All Answers highlighted. (All)

Arizona State University - IFT 383 Final Exam. All Answers highlighted.

Document Content and Description Below

IFT 383 Final • Question 1 1.5 out of 1.5 points ___________________ shows the count of the arguments (positional parameters) passed to the script. Selected Answer: $# Correct Answer... : • Question 2 1 out of 1.5 points Given a file foo1, replace all occurrences of the word “SHELL” with “CLEAR” from 5th line till end in only those lines that contains word “UNIX”. • Question 3 0 out of 1.5 points If an owner doesn’t have write permission on a file but their group has, what actions can they perform on the file? • Question 4 1.5 out of 1.5 points ___________________ keyword is used to define a subroutine in Perl. • Question 5 1.5 out of 1.5 points The output of the who command may have the same user id listed more than once. True or False? • Question 6 1.5 out of 1.5 points Given 2 files foo and bar, write a command to print the records which are common to both. Selected Answer: sort foo bar | uniq -d • Question 7 1.5 out of 1.5 points ___________________ considers the entire set of positional parameters as a single string • Question 8 1.5 out of 1.5 points Write the commands to create a directory such that anyone in the group can create a file and access any person’s file in it but nobody in the group should be able to delete a file other than the one they created. 1.5 out of 1.5 points In UNIX, directories, devices, terminals, printers, etc. are all treated as ___________________. Selected Answer: files Correct Answer: Evaluation Method Correct Answer Case Sensitivity Exact Match files • Question 10 1.5 out of 1.5 points To record comments in UNIX, we use the ___________________ character. • Question 11 1.5 out of 1.5 points How will you find the total disk space used by a specific user? • Question 12 1.5 out of 1.5 points UNIX files use CR-LF as the line terminating characters. True or False? • Question 13 0 out of 1.5 points A file in a file system with a block size of 512 bytes contains 2084 bytes. How many bytes of disk space does the file occupy? • Question 14 1.5 out of 1.5 points List the file descriptors for the three standard files? Selected Answer: Standard Input, Standard Output, Standard Error. • Question 15 0 out of 1.5 points Create an alias for a command to list only those users who have logged in more than once. Selected Answer: alias ISON="users" • Question 16 1.5 out of 1.5 points • Question 17 0 out of 1.5 points Which of the below logical comparisons can be performed using test condition in shell scripting? Selected Answer: e. Only a & b • Question 18 1.5 out of 1.5 points Perl is not a case sensitive language. True or False? • Question 19 1.5 out of 1.5 points ___________________ option is used to enable the escape characters in shell. Selected Answer: \ Correct Answer: Evaluation Method Correct Answer Case Sensitivity Exact Match -e • Question 20 1.5 out of 1.5 points How can a user find out all information about a specific user such as his default shell, full name, default directory, when and how long has he been using the system? • Question 21 1 out of 1.5 points How will you find the 99th line of a file “foo” using only tail and head command? • Question 22 1.5 out of 1.5 points What is the difference between grep and egrep? • Question 23 0 out of 1.5 points The commands placed in the ___________________ file are executed only once on login. Selected Answer: bash_profile Correct Answer: Evaluation Method Correct Answer Case Sensitivity Exact Match profile • Question 24 1.5 out of 1.5 points The path for sam’s home directory is /home/sam, and all his scripts have a reference to the directory sam/home/assets. If sam changes his home directory later to /users/sam, what should sam do to avoid his scripts becoming invalid? • Question 25 1.5 out of 1.5 points ___________________ command is used in shell for input from user. • Question 26 1.5 out of 1.5 points How will you emulate wc –l using awk? • Question 27 1.5 out of 1.5 points Write a command to print the 10th line of foo without using tail and head command. • Question 28 1.5 out of 1.5 points Given a file, use grep to find how many lines contain the word ‘UNIX’. • Question 29 1.5 out of 1.5 points List any 3 different types of commonly used shells on a typical Linux system? • Question 30 1.5 out of 1.5 points What will the following command accomplish? sed '1,3!d' filename • Question 31 1.5 out of 1.5 points What are scalar variables in Perl? • Question 32 1.5 out of 1.5 points How can you send a mail with a compressed file as an attachment? • Question 33 1.5 out of 1.5 points Devise wildcard patterns to match the following filenames: Create1, create3, create9 • Question 34 1.5 out of 1.5 points What command will you use to recover your work if the power was suddenly cut off while a vi session is active? • Question 35 0 out of 1.5 points Which wildcard pattern will be used to match the following filenames: Filename.DOC, filename.docx, filename.DOCX • Question 36 1.5 out of 1.5 points Which of the below commands would successfully create an array of names e. name = ("Severus Snape" "Harry Potter" "Ron Weasley") • Question 37 1.5 out of 1.5 points What does $? signify? Selected Answer: This command expands to the exit status of the most recently executed pipeline in a shell script Correct Answer: $? gives the exit status of the last command that was executed. • Question 38 1.5 out of 1.5 points Which of the following statements are true? A. awk and Perl interpret the whole script before executing B. awk and shell interpret the script line by line C. Perl interprets the whole script before executing D. awk and shell interpret the whole script before executing • Question 39 1.5 out of 1.5 points What do the following commands do? i) mv $HOME/include . ii) cp -r foo bar iii) mv * ../bar Selected Answer: i) Renames your HOME directory including all files in it to "." ii) Copies recursively the files foo into file bar iii)Moves all files to the previous directory, then to the directory bar • Question 40 1.5 out of 1.5 points ___________________ is used to get interactive input from user for an array. 60 out of 60 points Activity 1: Basic UNIX commands and utilities (4 points * 15 questions = 60 points) Capture your session with the script utility and name it FinalActivity1. Upload the session recording FinalActivity1 as part of your response. 1. Create a directory structure IFT383FinalExam/Activities/Activity1 in your home directory 2. Create a file using the cat command named classRoster 3. Add three records to your file with the following fields, separated by a comma a. Student ID b. First Name c. Last Name d. Grade e. Program of Study f. ASURITE ID (username) 4. Display the contents of the fiel classRoster 5. Move the file classRoster to the directory Activity1 6. Go to the Activity1 directory 7. Display the directory you are in 8. Add read, write and execute permissions for user and group to Activity1.dir 9. Create a new file called header using cat command whose contents are the field names, separated by a tab space a. Student ID b. First Name c. Last Name d. Grade e. Program of Study f. ASURITE ID (username) 10. Display the header file 11. Copy the contents of header into classRoster, as the first line 12. Replace the comma with a tab space using appropriate filters (such as cut, paste, tr, head, etc.) 13. Save this file as finalRoster.txt 14. Display the contents of the file finalRoster.txt 15. Convert the finalRoster to a UNIX file and save as rosterUNIX, perform a byte-by-byte comparison of the two files, and display the differences. Selected Answer: FinalActivity1 • Question 42 60 out of 60 points Activity 2: Shell scripting, SED, AWK and Perl (60 points) Submission Instructions: Submit a word document providing the responses to the 4 parts of Activity 2. For the output and script files, you may provide screenshots or simply copy the contents into your word document. Part I: Consider the file sety for below questions : (2 points * 3 questions = 6 points) 1. Provide the command (and the output) to display the lines that contain the literal character $ 2. Provide the command (and the output) to display the lines that contain the literal character . 3. Provide the command (and the output) to display the lines that contain the literal character ; Part II: Consider the file addr (3 points * 2 questions = 6points) 1. Write the command and provide a screenshot of the output to print all entries in the addr file for which the email address is from a valid educational institution(ends with .edu) 2. What is the difference between the two commands (or regular expressions) below? grep ‘*’ filename grep ‘\*’ filename Part III: Consider file addr , Provide the command as well as the output. (3 points * 12 questions = 36 points) 1. Use egrep with pipe to extract information for Elizi , Ma , and Jackson. 2. Use egrep with { } to extract lines with valid zip code 3. Use egrep with { } to extract lines with invalid zip code 4. Sort the addr file by phone number and print lines 1 thru 3. 5. Print the lines that end with valid zip code 6. Print the lines that end with invalid zip code 7. Add the string “School Email” next to all email addresses ending with “.edu” 8. Provide the sed command to get rid of the lines with private email addresses 9. Provide the command to print the rows that use imap number. 10. Provide a command to print only the first name, last name and email address of the person 11. Print the names, phone number, and zip in a tabular manner 12. Print the Last Name, First Name, Email Address and zip in a tabular format. Include the header identifying each field. Part IV: Provide the command, script file content and the output for the below questions (4 points * 3 questions = 12 points) 1. Write a script file to print the Last Name, First Name and email address of a student with a header and a footer. 2. Refer to the file groups and print the list of user names and their groups. Use a script file with a header and footer 3. Refer to the file groups and write an awk script file which would accept a userID input and display the group name for that userID as output. Files sety $1+ $2 = 4.3; This is a $5 note. This line does not contain a dot but has a $ This has a semi colon; Addr (Column 1 – LastName, Column2: First name, Column3: email address, Column4: phone number, Column5: zip code) Hilton,Tom,thilton.gmail.com,85281345,543781,imap987648790 Potter,Harry,[email protected],853645555,875234 Granger,Herminone,[email protected],9856017638,334567 Moe,Elizi,[email protected],3892000109,345678 Ta,Ma,[email protected],6747829191,85281 Five,Jackson,[email protected],7839209871,78339 Bean,Sean,[email protected],56783908156,78648 Turner,Sophie,[email protected],6784937689,9873329 groups (Column 1- Group ID, Column 2: Group Name, Column 3: UserID) 1,Griffindor,hpotter 2,Hufflepuff,cdiggory 4,Slytherin,ssnape 3,Ravenclaw,cchang 1,Griffindor,rweasley 1,Griffindor,hgranger Selected Answer: FinalActivity2.docx IFT 383 Final • Question 1 1.5 out of 1.5 points ___________________ shows the count of the arguments (positional parameters) passed to the script. Selected Answer: $# Correct Answer: • Question 2 1 out of 1.5 points Given a file foo1, replace all occurrences of the word “SHELL” with “CLEAR” from 5th line till end in only those lines that contains word “UNIX”. • Question 3 0 out of 1.5 points If an owner doesn’t have write permission on a file but their group has, what actions can they perform on the file? • Question 4 1.5 out of 1.5 points ___________________ keyword is used to define a subroutine in Perl. • Question 5 1.5 out of 1.5 points The output of the who command may have the same user id listed more than once. True or False? • Question 6 1.5 out of 1.5 points Given 2 files foo and bar, write a command to print the records which are common to both. Selected Answer: sort foo bar | uniq -d • Question 7 1.5 out of 1.5 points ___________________ considers the entire set of positional parameters as a single string • Question 8 1.5 out of 1.5 points Write the commands to create a directory such that anyone in the group can create a file and access any person’s file in it but nobody in the group should be able to delete a file other than the one they created. 1.5 out of 1.5 points In UNIX, directories, devices, terminals, printers, etc. are all treated as ___________________. Selected Answer: files Correct Answer: Evaluation Method Correct Answer Case Sensitivity Exact Match files • Question 10 1.5 out of 1.5 points To record comments in UNIX, we use the ___________________ character. • Question 11 1.5 out of 1.5 points How will you find the total disk space used by a specific user? • Question 12 1.5 out of 1.5 points UNIX files use CR-LF as the line terminating characters. True or False? • Question 13 0 out of 1.5 points A file in a file system with a block size of 512 bytes contains 2084 bytes. How many bytes of disk space does the file occupy? • Question 14 1.5 out of 1.5 points List the file descriptors for the three standard files? Selected Answer: Standard Input, Standard Output, Standard Error. • Question 15 0 out of 1.5 points Create an alias for a command to list only those users who have logged in more than once. Selected Answer: alias ISON="users" • Question 16 1.5 out of 1.5 points • Question 17 0 out of 1.5 points Which of the below logical comparisons can be performed using test condition in shell scripting? Selected Answer: e. Only a & b • Question 18 1.5 out of 1.5 points Perl is not a case sensitive language. True or False? • Question 19 1.5 out of 1.5 points ___________________ option is used to enable the escape characters in shell. Selected Answer: \ Correct Answer: Evaluation Method Correct Answer Case Sensitivity Exact Match -e • Question 20 1.5 out of 1.5 points How can a user find out all information about a specific user such as his default shell, full name, default directory, when and how long has he been using the system? • Question 21 1 out of 1.5 points How will you find the 99th line of a file “foo” using only tail and head command? • Question 22 1.5 out of 1.5 points What is the difference between grep and egrep? • Question 23 0 out of 1.5 points The commands placed in the ___________________ file are executed only once on login. Selected Answer: bash_profile Correct Answer: Evaluation Method Correct Answer Case Sensitivity Exact Match profile • Question 24 1.5 out of 1.5 points The path for sam’s home directory is /home/sam, and all his scripts have a reference to the directory sam/home/assets. If sam changes his home directory later to /users/sam, what should sam do to avoid his scripts becoming invalid? • Question 25 1.5 out of 1.5 points ___________________ command is used in shell for input from user. • Question 26 1.5 out of 1.5 points How will you emulate wc –l using awk? • Question 27 1.5 out of 1.5 points Write a command to print the 10th line of foo without using tail and head command. • Question 28 1.5 out of 1.5 points Given a file, use grep to find how many lines contain the word ‘UNIX’. • Question 29 1.5 out of 1.5 points List any 3 different types of commonly used shells on a typical Linux system? • Question 30 1.5 out of 1.5 points What will the following command accomplish? sed '1,3!d' filename • Question 31 1.5 out of 1.5 points What are scalar variables in Perl? • Question 32 1.5 out of 1.5 points How can you send a mail with a compressed file as an attachment? • Question 33 1.5 out of 1.5 points Devise wildcard patterns to match the following filenames: Create1, create3, create9 • Question 34 1.5 out of 1.5 points What command will you use to recover your work if the power was suddenly cut off while a vi session is active? • Question 35 0 out of 1.5 points Which wildcard pattern will be used to match the following filenames: Filename.DOC, filename.docx, filename.DOCX • Question 36 1.5 out of 1.5 points Which of the below commands would successfully create an array of names e. name = ("Severus Snape" "Harry Potter" "Ron Weasley") • Question 37 1.5 out of 1.5 points What does $? signify? Selected Answer: This command expands to the exit status of the most recently executed pipeline in a shell script Correct Answer: $? gives the exit status of the last command that was executed. • Question 38 1.5 out of 1.5 points Which of the following statements are true? A. awk and Perl interpret the whole script before executing B. awk and shell interpret the script line by line C. Perl interprets the whole script before executing D. awk and shell interpret the whole script before executing • Question 39 1.5 out of 1.5 points What do the following commands do? i) mv $HOME/include . ii) cp -r foo bar iii) mv * ../bar Selected Answer: i) Renames your HOME directory including all files in it to "." ii) Copies recursively the files foo into file bar iii)Moves all files to the previous directory, then to the directory bar • Question 40 1.5 out of 1.5 points ___________________ is used to get interactive input from user for an array. 60 out of 60 points Activity 1: Basic UNIX commands and utilities (4 points * 15 questions = 60 points) Capture your session with the script utility and name it FinalActivity1. Upload the session recording FinalActivity1 as part of your response. 1. Create a directory structure IFT383FinalExam/Activities/Activity1 in your home directory 2. Create a file using the cat command named classRoster 3. Add three records to your file with the following fields, separated by a comma a. Student ID b. First Name c. Last Name d. Grade e. Program of Study f. ASURITE ID (username) 4. Display the contents of the fiel classRoster 5. Move the file classRoster to the directory Activity1 6. Go to the Activity1 directory 7. Display the directory you are in 8. Add read, write and execute permissions for user and group to Activity1.dir 9. Create a new file called header using cat command whose contents are the field names, separated by a tab space a. Student ID b. First Name c. Last Name d. Grade e. Program of Study f. ASURITE ID (username) 10. Display the header file 11. Copy the contents of header into classRoster, as the first line 12. Replace the comma with a tab space using appropriate filters (such as cut, paste, tr, head, etc.) 13. Save this file as finalRoster.txt 14. Display the contents of the file finalRoster.txt 15. Convert the finalRoster to a UNIX file and save as rosterUNIX, perform a byte-by-byte comparison of the two files, and display the differences. Selected Answer: FinalActivity1 • Question 42 60 out of 60 points Activity 2: Shell scripting, SED, AWK and Perl (60 points) Submission Instructions: Submit a word document providing the responses to the 4 parts of Activity 2. For the output and script files, you may provide screenshots or simply copy the contents into your word document. Part I: Consider the file sety for below questions : (2 points * 3 questions = 6 points) 1. Provide the command (and the output) to display the lines that contain the literal character $ 2. Provide the command (and the output) to display the lines that contain the literal character . 3. Provide the command (and the output) to display the lines that contain the literal character ; Part II: Consider the file addr (3 points * 2 questions = 6points) 1. Write the command and provide a screenshot of the output to print all entries in the addr file for which the email address is from a valid educational institution(ends with .edu) 2. What is the difference between the two commands (or regular expressions) below? grep ‘*’ filename grep ‘\*’ filename Part III: Consider file addr , Provide the command as well as the output. (3 points * 12 questions = 36 points) 1. Use egrep with pipe to extract information for Elizi , Ma , and Jackson. 2. Use egrep with { } to extract lines with valid zip code 3. Use egrep with { } to extract lines with invalid zip code 4. Sort the addr file by phone number and print lines 1 thru 3. 5. Print the lines that end with valid zip code 6. Print the lines that end with invalid zip code 7. Add the string “School Email” next to all email addresses ending with “.edu” 8. Provide the sed command to get rid of the lines with private email addresses 9. Provide the command to print the rows that use imap number. 10. Provide a command to print only the first name, last name and email address of the person 11. Print the names, phone number, and zip in a tabular manner 12. Print the Last Name, First Name, Email Address and zip in a tabular format. Include the header identifying each field. Part IV: Provide the command, script file content and the output for the below questions (4 points * 3 questions = 12 points) 1. Write a script file to print the Last Name, First Name and email address of a student with a header and a footer. 2. Refer to the file groups and print the list of user names and their groups. Use a script file with a header and footer 3. Refer to the file groups and write an awk script file which would accept a userID input and display the group name for that userID as output. Files sety $1+ $2 = 4.3; This is a $5 note. This line does not contain a dot but has a $ This has a semi colon; Addr (Column 1 – LastName, Column2: First name, Column3: email address, Column4: phone number, Column5: zip code) Hilton,Tom,thilton.gmail.com,85281345,543781,imap987648790 Potter,Harry,[email protected],853645555,875234 Granger,Herminone,[email protected],9856017638,334567 Moe,Elizi,[email protected],3892000109,345678 Ta,Ma,[email protected],6747829191,85281 Five,Jackson,[email protected],7839209871,78339 Bean,Sean,[email protected],56783908156,78648 Turner,Sophie,[email protected],6784937689,9873329 groups (Column 1- Group ID, Column 2: Group Name, Column 3: UserID) 1,Griffindor,hpotter 2,Hufflepuff,cdiggory 4,Slytherin,ssnape 3,Ravenclaw,cchang 1,Griffindor,rweasley 1,Griffindor,hgranger Selected Answer: FinalActivity2.docx [Show More]

Last updated: 1 year ago

Preview 1 out of 12 pages

Reviews( 0 )

$13.00

Add to cart

Instant download

Can't find what you want? Try our AI powered Search

OR

GET ASSIGNMENT HELP
130
1

Document information


Connected school, study & course


About the document


Uploaded On

Feb 26, 2021

Number of pages

12

Written in

Seller


seller-icon
SuperSolutions©

Member since 3 years

338 Documents Sold


Additional information

This document has been written for:

Uploaded

Feb 26, 2021

Downloads

 1

Views

 130

Document Keyword Tags

More From SuperSolutions©

View all SuperSolutions©'s documents »

Recommended For You


$13.00
What is Browsegrades

In Browsegrades, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Browsegrades · High quality services·