Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Linux Tools for Developers

Total questions: 15

Worksheet time: 9mins

Name
Class
Date
1.

1.Which command will list all files under the current directory with a .cfg extension, and then delete them?

a)

find . -exec rm {} ';' -name "*.cfg"

b)

find . -name "*.cfg" -exec rm {} ';'

c)

find -exec rm {} ';' -name "*.cfg" .

d)

find -name "*.cfg" . -exec rm {} ';'

2.

2.Which command will list all files and directories on the system with cfg in their name?

a)

ls -l $(locate cfg)

b)

find cfg

c)

locate

d)

locate cfg -exec ls -l {} ';'

3.

3.Which command will find all files and directories in the system whose name ends with cfg?

a)

locate -r "^cfg"

b)

locate cfg$

c)

locate cfg

d)

locate -r "cfg$"

4.

4.Which commands can change all occurrences within a file of the string boris to natasha (Select all answers that apply)?

a)

sed -e s:boris:natasha:g file

b)

sed -e s/boris:natasha/g file

c)

sed -e s\boris\natasha\g file

d)

sed -e s/boris/natasha/g file

5.

5.Which command will print out all lines beginning with "X" in all files in the current directory?

a)

grep $X *

b)

grep "X$" *

c)

grep "^X" *

6.

6. Which command is used to combine three files into a fourth file?

a)

cat file1 file2 file3 > file4

b)

cp file1 file2 file3 > file4

c)

cat file1 > file2 > file3 | file4

d)

cat file1 > file2 > file3 > file4

7.

7.Which of the following commands can be used to view the last 15 lines of a file (Select all answers that apply)?

a)

tail=15 some_file

b)

tail +15 some_file

c)

tail -n15 some_file

d)

tail -15 some_file

8.

8.Which of the following commands will replace all instances of the word "dog" with "pig" in the file named some_file and send the output to stdout (Select all answers that apply)?

a)

sed -e s/dog/pig/ some_file

b)

cat some_file | sed -e s/dog/pig/g

c)

sed -e s:dog:pig:g some_file

d)

sed -e s/dog/pig/g some_file

9.

9.Which commands can be used to print the lines that contain the numbers 0–5 in a file (Select all answers that apply)?

a)

grep [0,1,2,3,4,5] filenamegrep [0,1,2,3,4,5] filename

b)

grep {0-5} filenamegrep {0-5} filename

c)

grep [0-5] filenamegrep [0-5] filename

d)

grep [-e0 -e1 -e2 -e3 -e4 -e5] filenamegrep [-e0 -e1 -e2 -e3 -e4 -e5] filename

10.

10.Which command is used to extract columns from a file to work on them later?

a)

wc

b)

cut

c)

tr

d)

tee

11.

11.Which of the following commands are equivalent (Select all answers that apply)?

a)

if test -f file.c ; then cat file.c ; fi

b)

if [ -f file.c ] ; then cat file.c ; fi

c)

if [[ -f file.c ]] ; then cat file.c ; fi

d)

[[ -f file.c ]] && cat file.c

12.

12.Which commands will list all files under the current directory ending in "~" (Select all answers that apply)?Note: Output lists may differ in format.

a)

find . -name "*~" -exec ls -l {} ';'

b)

ls -l $(find . -name "*~")

c)

find . -name "*~" | xargs ls -l

d)

find . -name "*~" -ls

13.

13.Functions (subprograms) are useful in bash scripts because (Select all answers that apply):

a)

It is better not to have to call another script to get things done

b)

They eliminate the need to retype the same set of commands more than once

c)

They make things easier to read and comprehend

14.

14.How would you get the value of a variable named VAR into a script?

a)

ask VAR

b)

read VAR

c)

accept VAR

d)

input VAR

15.

15.Select the correct statement:

a)

A bash function must be placed before it is used in a script

b)

A bash function can be placed anywhere in a script, before or after it is used