Question

UNIX COMMANDS Task B Create a one-line command, using the famous.dat file, to add the word...

UNIX COMMANDS

Task B
Create a one-line command, using the 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 or 5 or 6 or 7 or 9 in the zip code.
Hint: this is the same as NOT 0 or 1 or 2 or 3 or 8.

Task E
Using only the grep command, search all files with names that end in .htm followed by anything (use .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 or no file
Hint: use two command arguments and 2>

Homework Answers

Answer #1

Please try posting the other questions separately if you need an answer to them. I can provide answers to only the first part in the allotted time and as per company policy, I am allowed to answer only one task. However, I am providing you with a solution to the 2nd task as well. Give me an up vote if you like my answer.

TASK B :

head -n 9 famous.dat | sed -r 's/(2nd|3rd)/\1 STREET/g' //This will add street only to first 9 lines

sed -r 's/(2nd|3rd)/\1 STREET/g' famous.dat | head -n 9 famous.dat //this will add street to all the lines and will display 9 lines after that.

Task C:

grep '1.[01]$' famous.dat

Know the answer?
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
Similar Questions
Write UNIX commands to perform the following tasks. Each task must use exactly one line of...
Write UNIX commands to perform the following tasks. Each task must use exactly one line of command. Unless stated otherwise, all files are assumed to be at your current working directory. a) (10 points) Print your current working directory into a file named file1 b) (10 points) Assume that your current working directory is NOT the same as your home directory. Print all file and subdirectory names of your home directory into a file named file2. c) (15 points) Copy...
1. By convention, how are configuration files separated from regular files? (NOTE: A practical effect of...
1. By convention, how are configuration files separated from regular files? (NOTE: A practical effect of the separation is that they are not displayed by the default version of the ls command)                         a. the prefix "rc" (rc.filename)               c. the extension .cfig                         b. a dot (.) at the beginning                    d. by having the SUID bit set 2. The IP address which is reserved for local loopback (equivalent to "localhost") is:                         a. 255.255.255.0                                   c. 192.168.70.1...
please can you make it simple. For example using scanner or hard coding when it is...
please can you make it simple. For example using scanner or hard coding when it is a good idea instead of arrays and that stuff.Please just make one program (or class) and explain step by step. Also it was given to me a txt.htm 1.- Write a client program and a server program to implement the following simplified HTTP protocol based on TCP service. Please make sure your program supports multiple clients. The webpage file CS3700.htm is provided. You may...