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...
please use linux/unix command terminal to complete, step 1 1-create a new directory named by inlab4...
please use linux/unix command terminal to complete, step 1 1-create a new directory named by inlab4 enter directory inlab4 create a new file named by reverse.c with the following contents and then close the file: /*reverse.c */ #include <stdio.h> reverse(char *before, char *after); main() { char str[100]; /*Buffer to hold reversed string */ reverse("cat", str); /*Reverse the string "cat" */ printf("reverse(\"cat\")=%s\n", str); /*Display result */ reverse("noon", str); /*Reverse the string "noon" */ printf("reverse(\"noon\")=%s\n", str); /*Display result */ } reverse(char *before,...
Description: You will develop a small "text-based shell utility" ("ts") for Unix (or similar OS). A...
Description: You will develop a small "text-based shell utility" ("ts") for Unix (or similar OS). A common complaint of the most-used UNIX (text) shells (Bourne, Korn, C) is that it is difficult to remember (long) file names, and type "long" command names. A "menu" type shell allows a user to "pick" an item (file or command)from a "menu". You will display a simple menu, the following is a suggestion (you may change format): Current Working Dir: /home/os.progs/Me It is now:...
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...
Please program in JAVA: Program each option such as delete line and such. Your program will...
Please program in JAVA: Program each option such as delete line and such. Your program will be a line editor. A line editor is an editor where all operations are performed by entering commands at the command line. Commands include displaying lines, inserting text, editing lines, cutting and pasting text, loading and saving files. For example, a session where the user enters three lines of text and saves them as a new file may appear as: Menu: m Delete line:...
1. Vim commands: a. How do you auto indent your program? b. Explain what the following...
1. Vim commands: a. How do you auto indent your program? b. Explain what the following commands do: dd, y3, p, :set cindent (1 pt) VIM exercises These exercises on the computer need to be repeated by each student in the pair. This is to ensure that both students understand how to get around in Linux!!! For this part of the lab, you will create a .vimrc file that will help you develop your C++ programs using VIM. First, we...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT