Unix Questions and Answers – Operator-Command Combinations

This set of Unix Multiple Choice Questions & Answers (MCQs) focuses on “Operator-Command Combinations”.

1. An operator can’t perform any function without being combined with a command or itself.
a) True
b) False
View Answer

Answer: a
Explanation: An operator alone cannot perform any function unless it is combined with a command or itself. For example, by using dd or yy we can delete or copy a line respectively.

2. For deleting the line form current cursor to the end of the line, we can use:
a) $
b) d$
c) dd
d) $d
View Answer

Answer: a
Explanation: dd command is a combination of the d operator with itself. vi can perform complex deletion when this operator is combined with a command of the command mode. For example,

d$        //delete entire line fro current cursor location to end of line

advertisement
advertisement

3. dw will ________
a) deletes one line
b) deletes one word
c) deletes one character
d) deletes one sentence
View Answer

Answer: b
Explanation: dd command is a combination of the d operator with itself. vi can perform complex deletion when this operator is combined with a command of the command mode. For example,

dw            // deletes one word
3dw           // deletes 3 words

advertisement

4. For yanking text, ___ is used.
a) d
b) y
c) c
d) G
View Answer

Answer: b
Explanation: The y operator is used for yanking (copying) text. It is used in the same way as d operator is used i.e. it is also combined with itself or with another command. For example,

5yy            // yanks five lines

advertisement

5. For pasting text, ____ is used.
a) p or P
b) d or D
c) C
d) x or X
View Answer

Answer: a
Explanation: After yanking text with yy, we can paste it using either p or P. p paste the text below the current line while P paste the text above the current line.

6. c operator is used for changing the text.
a) True
b) False
View Answer

Answer: a
Explanation: For changing text, c operator is used. This operator is also combined with a command to perform the replacement. If dw deletes a word, cw changes it. This operator works in input mode. For example, to change the text from the present cursor location up to the end of line, use
c$ or C

7. To change entire lines, ____ is used.
a) cc
b) CC
c) dd
d) c$
View Answer

Answer: a
Explanation: For changing text, c operator is used. This operator is also combined with a command to perform the replacement. To change entire lines, use the cc command.

8. Which operator is used in vi to filter text?
a) %%
b) &&
c) $
d) !
View Answer

Answer: d
Explanation: vi provides a marvellous feature of allowing UNIX filter to act on the text that’s displayed on the terminal. For filtering text screen,
1. move to the beginning of the text to be acted upon and press !
2. move to the other end of the text using navigation command like G
3. Enter the command to act on the text.

9. To delete from current cursor upto the first occurrence of }, which of the following will be used?
a) dd$}
b) d /
c) d / }
d) }
View Answer

Answer: c
Explanation: We can perform many functions using operator-command combinations. For example, d / } will deletes from the current cursor upto first occurrence of } .

10. The command df. will _____
a) deletes entire line
b) deletes entire paragraph
c) deletes from current cursor up to first occurrence of
d) deletes zero lines
View Answer

Answer: c
Explanation: The command df. is another example of operator-command combination. It deletes from cursor to first occurrence of a dot.

11. To yank from current cursor up to first occurrence of string str in reverse direction, we can use:
a) y?str
b) y!str
c) yy str
d) yy ! str
View Answer

Answer: a
Explanation: The command y?str is another example of operator-command combination. The operator ? is used with y operator for yanking a string in reverse direction.

12. The following command will_________

!! tr ‘[a-z]’  ‘[A-Z]’

a) throw an error
b) undefined behavior
c) changes the case of the current line from lower to uppercase
d) changes the case of current line from upper to lowercase
View Answer

Answer: c
Explanation: The ! operator when doubled is used for operating on current line. For example, we can change the case of current line from lowercase to uppercase by using the above command.

13. The command c0 will change the text from current cursor to the end of line.
a) True
b) False
View Answer

Answer: b
Explanation: The command c0 will change the text from current cursor to the beginning of line.

14. To sort all lines from current cursor to end of line, ____ can be used.
a) sort .,$
b) sort !G
c) sort !,G
d) !Gsort
View Answer

Answer: d
Explanation: The sort command is combined with ! and G operator for sorting from current cursor to the end of the line.

15. Which of the following is not a valid operator-command combination?
a) 5dd
b) yy5
c) cc
d) yG
View Answer

Answer: b
Explanation: The command yy5 is not a valid one as we cannot prefix the command yy with an integer value.

Sanfoundry Global Education & Learning Series – Unix.

To practice all areas of Unix, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.