Question

The purpose of this lab assignment is to practice searching in Unix and using regular expressions....

The purpose of this lab assignment is to practice searching in Unix and using regular expressions.

Task A:
Use the find command to find all directories under /pub/cs/ whose name is cs160a. Be sure to only display the results that match, do not display any error output.
Hint: use: 2>/dev/null.

Task B:
Create a one-line command, using he famous.dat file, to add the word " STREET" to the address, for all who live on 2nd or 3rd.
For example: '2nd' becomes "2nd STREET" and '3rd' becomes "3rd STREET".
Display only the first 9 lines.
Hint: use 2 sed statements with pipes.

Task C:
Display all lines in famous.dat that end in 0 or 1, and have a 1 in the 3rd from the last column.
For example lines ending in 120 and 131 would be displayed.

Task D:
Display all lines in famous.dat that have only 4, 5, 6, 7 and 9 in the zip code.
HINT: this is the same as NOT 0,1,2,3 or 8.

Task E:
Using only the grep command, search all files with names that end in either .html or .htm under the$HOME/public_html directory and display any lines that contain body tags (containing '<body>'). No other output should be displayed even if there is no public_html directory.
Hint: use two command arguments and 2>

Sample Output

A: (note: output may change depending on instructors teaching in any given semester)
/pub/cs/cmetzler/bin/cs160a
/pub/cs/cconner/cs160a
/pub/cs/jpotter/cs160a
/pub/cs/gboyd/cs160a

B:
    01 m motzart       amadeous         25 2nd STREET 94233
    02 m guthrie       woody                23 2nd STREET 94223
    03 f simone         nina                   27 2nd STREET 94112
    04 m lennon        john                   29 2nd STREET 94221
    05 f harris           emmylou            20 2nd STREET 94222
    06 m marley        bob                22 2nd STREET 94112
    07 f marley         rita                     26 2nd STREET 94212
    08 f warwick        dione                 26 2nd STREET 94222
    09 m prine          john                   35 3rd STREET 94321

C:
    26 m moose          bullwinkle      16 1st 94111

D:
    19 f mitchell         joni             40 4th 94444
    24 m heinlein       robert         74 7th 94765
    25 m asimov        isaac          75 7th 94777
    38 f tubman         harriet        50 5th 95555
    41 m douglas       frederick    66 6th 94666
    44 f parks            rosa           72 7th 94777

E:
Note: no output may be produced unless you have files containing '<body>'

0 0
Add a comment Improve this question Transcribed image text
Answer #1

answer a:
***********

ubuntu17 (fresh) [Running] - Oracle VM VirtualBox File Machine View Input Devices Help You have the Auto capture keyboard opt

as i do not have /pub/cs directory so its not showing anything

Answer b:
***********

ubuntu17 (fresh) [Running]- Oracle VM VirtualBox File Machine View Input Devices Help Terminal Thu 21:50 Activities madhav@ma

Answer c:
***********

ubuntu17 (fresh) [Running] - Oracle VM VirtualBox File Machine View Input Devices Help Terminal Thu 21:58 Activities madhav@m

WITHOUT PROPER FAMOUS.DAT FILE CANT FIND THE PROPER ANSWER BUT I TRIED MY LEVEL BEST.

Answer d:
***********

egrep "[45679]{5}$" famous.dat


Answer e:
************

grep -r --include=*.{html,htm} "<body>" $HOME/public_html 2>/dev/null

Add a comment
Know the answer?
Add Answer to:
The purpose of this lab assignment is to practice searching in Unix and using regular expressions....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Unix/Linux The purpose of this lab is to practice the commands to manage and organize files...

    Unix/Linux The purpose of this lab is to practice the commands to manage and organize files and directories: How would one go about this? Thanks. Task 1: Preliminaries: 1) If you have not already done so, create a directory called bin under your HOME directory. 2) If you have not already made a copy (using ftp) of the file called famous.dat from the Assignment#1, do that now. 3) Make bin the active/working directory. Task 2: Perform all of the following...

  • from the file "classfile.dat" bellow do the following commands : a. Display the contents of the...

    from the file "classfile.dat" bellow do the following commands : a. Display the contents of the file sorted by last name. Ignore leading white space . b. Display lines, with line numbers, for Computer Science majors. c. Display lines for students whose e-mail addresses end with .edu. d. Display all lines but show only the last name and GPA, sorted by GPA. 2. Search your home directory and all sub-directories, and display pathnames of all C++ program files. Terminate your...

  • 1) Write a single line UNIX command to list all sh files matching the multiple conditions...

    1) Write a single line UNIX command to list all sh files matching the multiple conditions below: • at directory "/home/test" • filename containing "exam" 2) Write a single line UNIX command to check if "/home/exam2" in the PATH variable. 3) How to obtain the value of command line arguments in a shell program? 4) Write a single line UNIX command to run an executable Java program Hello at background and output the number of lines in the result. 5)...

  • Objective : Write a C Shell script which copies all files(*.java and *.class) from your home dire...

    Objective : Write a C Shell script which copies all files(*.java and *.class) from your home directory to a new one, and Analyze the new directory information such as number of files, user permissions, and disk usage. Sample Output:                                                    << CS Directory Analysis >>      Date:   ============================================================ Current Directory: /home/tomss New Directory Created : /home/tomss/pgm01 File information Total Number of files : 22 files Directory files:   0 files Plain text files:   10 files File have read permissions: 3 files File have...

  • Assignment 2 In this assignment, you will write two short programs to solve problems using recursion....

    Assignment 2 In this assignment, you will write two short programs to solve problems using recursion. 1. Initial Setup Log in to Unix. Run the setup script for Assignment 2 by typing: setup 2 2. Towers of Hanoi Legend has it that in a temple in the Far East, priests are attempting to move a stack of disks from one peg to another. The initial stack had 64 disks threaded onto one peg and arranged from bottom to top by...

  • 1) Echo the input: First, you should make sure you can write a program and have...

    1) Echo the input: First, you should make sure you can write a program and have it compile and run, take input and give output. So to start you should just echo the input. This means you should prompt the user for the plaintext, read it in and then print it back out, with a message such as "this is the plaintext you entered:". [4 points, for writing a working program, echoing the input and submitting the program on the...

  • /*hello everyone. my question is mostly related to the garagetest part of this assignment that i've...

    /*hello everyone. my question is mostly related to the garagetest part of this assignment that i've been working on. i am not sure how to read the file's contents AND put them into variables/an array. should it be in an arraylist? or maybe a regular array? or no arrays at all? i am also not sure how to call the factory method from garagec. i'm thinking something along the lines of [Garage garage = new GarageC.getInstance("GarageC", numFloors, areaofEachFloor);] but i...

  • Use program control statements in the following exercises: Question 1 . Write pseudocode for the following:...

    Use program control statements in the following exercises: Question 1 . Write pseudocode for the following: • Input a time in seconds. • Convert this time to hours, minutes, and seconds and print the result as shown in the following example: 2 300 seconds converts to 0 hours, 38 minutes, 20 seconds. Question 2. The voting for a company chairperson is recorded by entering the numbers 1 to 5 at the keyboard, depending on which of the five candidates secured...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT