PART 1: Executing the grep Command In this part of the lab, you will formulate a
ID: 3636922 • Letter: P
Question
PART 1: Executing the grep Command
In this part of the lab, you will formulate a command using grep to filter information from a file named "fortunes.txt," located in the Element K Unix environment. The fortunes.txt file is an MS-DOS file and will need to be converted to the UNIX text file format using the dostounix command described at the end of this week's lecture. You will print the line number containing the specified pattern below. Use the file (Wk2 Lab part1 fortune file.docx) provided in Doc Sharing as a template for what you should submit for this section of the lab. The list below provides you with specific patterns to search or filter. Your job is to document the result of each of the commands you execute in the system.
Pattern to search:
Find all lines that contain W or C.
Find all lines that contain q, x, or z.
Find all lines that have the pattern ss some place.
Find all lines that have a number (digit from 0-9).
Find all lines that start with a number (digit from 0-9).
Find all lines that end with "ing" and a period (.).
Find all lines that contain prog.
(fortunes.txt file below)
1.79 x 10^12 furlongs per fortnight -- it's not just a good idea, it's the law!
186,282 miles per second: It isn't just a good idea, it's the law!
A billion here, a couple of billion there -- first thing you know it adds up to be real money. -- Senator Everett McKinley Dirksen
A bird in the bush usually has a friend in there with him.
A bird in the hand is worth what it will bring.
A bird in the hand makes it awfully hard to blow your nose.
A journey of a thousand miles begins with a cash advance.
A jury consists of 12 persons chosen to decide who has the better lawyer.
A lack of leadership is no substitute for inaction.
A language that doesn't affect the way you think about programming is not worth knowing.
A language that doesn't have everything is actually easier to program in than some that do. -- Dennis M. Ritchie
A large number of installed systems work by fiat. That is, they work by being declared to work. -- Anatol Holt
Law of Computer Programming: Make it possible for programmers to write in English and you will find that programmers cannot write in English.
A lot of people are afraid of heights. Not me. I'm afraid of widths.
A professor is one who talks in someone else's sleep.
A sine curve goes off to infinity or at least the end of the blackboard.
A successful [software] tool is one that was used to do something undreamed of by its author.
A transistor protected by a fast-acting fuse will protect the fuse by blowing first.
After an instrument has been assembled, extra components will be found on the bench.
Bell Labs Unix -- Reach out and grep someone.
Beware of bugs in the above code; I have only proved it correct, not tried it.-- Donald Knuth
If computers get too powerful, we can organize them into a committee -- that will do them in.
Brook's Law: Adding manpower to a late software project makes it later.
Brooke's Law: Whenever a system becomes completely defined, some damn fool discovers something which either abolishes the system or expands it beyond recognition.
bogosity: The degree to which something is bogus
Berkeley Quality Software(often abbreviated `BQS'): Term used in a pejorative sense to refer to software that was apparently created by rather spaced-out hackers late at night to solve some unique problem. It usually has nonexistent, incomplete, or incorrect documentation, has been tested on at least two examples, and core dumps when anyone else attempts to use it. This term was frequently applied to early versions of the dbx(1) debugger.
LER: A light-emitting resistor (that is, one in the process of burning up).
Lubarsky's Law of Cybernetic Entomology: "There is always one more bug."
In the evil program, constants aren't and variables won't/
C makes it easy for you to shoot yourself in the foot. C++ makes that harder, but when you do, it blows away your whole leg. -- Bjarne Stroustrup
Cache: A very expensive part of the memory system of a computer that no one is supposed to know is there.
- (Wk2 Lab part1 fortune file.docx) below
(task) (enter grep command) (enter Which line numbers?)
1. Find all lines that contain W or C.
2. Find all lines that contain q, x, or z.
3. Find all lines that have the pattern "ss" someplace.
4. Find all lines that have a number ( digit from 0-9).
54. Find all lines that start with a number ( digit from 0-9).
65. Find all lines that end with "ing" and a period (.).
76. Find all lines that contain "prog".
Explanation / Answer
1. grep "[WC]" fortunes.txt 2. grep "[qxz]" fortunes.txt 3. grep "ss" fortunes.txt 4. grep "[0-9]" fortunes.txt 5. grep "^[0-9]" fortunes.txt 6. grep "ing.$" fortunes.txt 7. grep "prog" fortunes.txt
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.