Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Which command will find all files under /me/mine/ whose name is horses find -

ID: 3862534 • Letter: 1

Question

1.

Which command will find all files under /me/mine/ whose name is horses

find -af /me/mine -name horses

2.

sed 's/[BW]ill/William/g' somefile

changes the first occurance of 'Bill' or 'Will' to 'William' in somefile

3.

Write a grep command
to search for the string Carl Jung in the contents of a file called
analysis
under the directory
/psycho

grep "Carl Jung" /psycho/analysis/

4.

Write a regular expression
to match lines with the following criteria:
+ begins with the single digit 8 or 9
+ contains a lower case letter somewhere in the middle (line may be any length)
+ and ends with the dash character: -

^[8-9][a-z]-$

5.

What is the Unix command to find all student files named my.dat
anywhere under the /home directory

6.

What is displayed?
ls >/dev/null | grep 2>/dev/null

no output is displayed

7.

The most important thing to be able to do with sed is to

do a simple string substitution

8.

Which of the following commands with regular expressions will produce output?

none of the above display output

9.

Which of the following is considered an extended regular expression?

all of the above

10.

Write a regular expression that will find all lines in a file named twodots that contain at least two dots.
(So a.b.c, a..bc, and a..b.c are displayed, but not a.bc)

'..*.'

11.

Which regular expression is the same as 'cc*'

cc?

12.

Which command will match lines with 3 consecutive capital letters or more?

grep '*[[:upper:]][[:upper:]][[:upper:]]*'

13.

Which regular expression will find all lines in the file termApplications that contain valid birth month in the form: 1 letter month abbreviation followed by a 2 digit year, where the month abbreviation can only be: a, d, f, j, m , n, o, or s.
(So a97 and J04 would match, but not t45)

[adfjmnos][ADFJMNOS][0-9][0-9]

14.

What is the output of the following?

cat finalFile
1
12
123
1234
12345
bash-3.2$ grep '...' finalFile | wc -l

4 or more

15.

Write a regular expression that will find all lines in a file named meetingMinutes that end in a question mark '?'

'*?$'

16.

Identify the regular expression meta-character with the same interpretation as the the filename wildcard

square brackets

17.

Which of the following is NOT a valid metacharacter for regular expressions?

^

18.

What is the output of the following:

$ ls public_html/gifs | sort | grep '.' | wc -l

a sorted list of all lines in all files in the gifs subdirectory

19.

What permissions are necessary for the following:
grep 'times' /local/finalMSG

x permission on the directory /local

20.

Which command has an command option to ignore any difference in upper or lower case letters?

none of the above

21.

$ cat poets
Hafiz
oliver
HD
redHawk

Which displays the following?
2:oliver

grep -nvi H poets

22.

Given the following:
$ cat poets.data
mary oliver 16
octavio paz 8
sharon olds 4
wallace stevens 24
red hawk 5
What is printed?
grep eliot poets.data

bash error: eliot is not in poets.data

23.

In vi what would I type to replace ALL occurrences of the word Unix with the word Linux?

s/Unix/Linux/

24.

Which does not create a file called ipassed that contains IPassed?

echo IPassed>ipassed

25.

Which is true about searching with grep and find?

Please answer questions 1 - 25.

find -L /me/mine -name horses

Explanation / Answer

The answer to the first question is

find -L /me/mine -name horses

2) the answer is changes all occurances of 'Bill' or 'Will' to 'William' in somefile