Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

1.

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

find -L /me/mine -name horses
grep horses /me/mine
find -a /me/mine -name horses 2>/dev/null

find -af /me/mine -name horses

2.

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

changes all occurances of 'BWill' to William in somefile
changes all occurances of 'Bill' or 'Will' to 'William' in somefile
incorrectly formed sed statement

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
grep "Carl Jung" psycho/analysis
grep "Carl Jung" /psycho/analysis

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].*-$
^[8-9]*[a-z]*-$
^[8-9][a-z].*-$

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

5.

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

find /home "my.dat"
find /home -name "my.dat"
find -name /home "my.dat"
find "my.dat" /home

6.

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

all files in the current directory
>/dev/null
the output can be displayed with: cat /dev/null
2>/dev/null

no output is displayed

7.

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

do cut and paste
delete lines from a file
select lines from a file

do a simple string substitution

8.

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

echo 12 | grep '.*'
all of the above display output
echo 123 | grep '.*'
echo 1 | grep '.*'

none of the above display output

9.

Which of the following is considered an extended regular expression?

x{8}
x?
x+

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]*
cc+
c**
c+

cc?

12.

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

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

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)

[adfjmnosADFJMNOS][0-9][0-9]
[adfjmnosADFJMNOS,0-9,0-9]
*[adfjmnos][ADFJMNOS][0-9][0-9]*

[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

1
2
3
0

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

*
none
?

square brackets

17.

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

?
$
all are valid metacharacters for regular expressions
*

^

18.

What is the output of the following: $ ls public_html/gifs | sort | grep '.' | wc -l

the number if files in the gifs subdirectory
alphabetical display of all files in the gifs subdirectory

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

both of the above are true
r permission on the file finalMSG

x permission on the directory /local

20.

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

all of the above
find
grep
sort

none of the above

21.

$ cat poets Hafiz oliver HD redHawk Which displays the following? 2:oliver

none of the above
grep -nv H poets
grep -nvi h poets
all of the above

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

0
no output is produced
mary oliver 16

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/
:%s/Unix/Linux/g

s/Unix/Linux/

24.

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

touch IPassed>ipassed
pico ipassed IPassed Press:control-X
cat >ipassed IPassed Press:control-D

echo IPassed>ipassed

25.

Which is true about searching with grep and find?

All of the above
grep searches the contents of a group of files
grep searches the contents of a single file
find searches the names of files in a group of directories

Please answer questions 1 - 25.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

a. What are S, F, and P? Pg45

Answered: 1 week ago