Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Search and replace operations can also use regular expressions for matching multiple patterns.(a) True(b) FalseThe question was asked by my college director while I was bunking the class.My doubt stems from Commands for Searching, Replacing and Substituting in Vi Editor topic in division The Vi Editor of Unix

Answer»

Correct answer is (a) True

Best explanation: Both search and replace operations can make use of REGULAR expressions for MATCHING MULTIPLE patterns.

2.

Which one of the following commands will be used to delete all the instances of string ‘manager’ in file003?(a) 1,$s/manager/ /g(b) %s/manager/director/g(c) 1,$s/professor/director(d) %s/manager/ /I have been asked this question during an online interview.I would like to ask this question from Commands for Searching, Replacing and Substituting in Vi Editor in section The Vi Editor of Unix

Answer»

The CORRECT OPTION is (a) 1,$s/manager/ /g

To explain: When the TARGET pattern is left empty, then all the instances of the source pattern are deleted within the addressed lines in the file.

3.

Which of the following flag will be used for interactive substitution?(a) g(b) G(c) gc(d) cgThe question was asked by my school teacher while I was bunking the class.I want to ask this question from Commands for Searching, Replacing and Substituting in Vi Editor in section The Vi Editor of Unix

Answer» CORRECT option is (c) gc

The best I can explain: For selectively replacing a STRING we can use ‘gc’ flag. Here ‘c’ is used as a confirmatory parameter at the end. Each line is SELECTED in turn and then waits for our response, whether to replace the selected PATTERN or not. A ‘y’ PERFORMS the substitution and any other response doesn’t.
4.

Which of the following is a correct syntax for performing substitution on a file?(a) :address/source_pattern/target_pattern/flag(b) :address/target_pattern source_pattern/flag(c) :address/flag(d) :addressI have been asked this question in an interview for job.My doubt is from Commands for Searching, Replacing and Substituting in Vi Editor topic in division The Vi Editor of Unix

Answer»

Correct ANSWER is (a) :address/source_pattern/target_pattern/flag

Explanation: For performing substitution, the correct syntax is:

:address/source_pattern/target_pattern/flag

For example, if we want to PERFORM substitution on line number 1 to 50, SOURCE pattern is ‘directory’ and TARGET pattern is ‘member’ then,

5.

We cannot leave the flag field empty while performing the substitution.(a) True(b) FalseThe question was posed to me in a national level competition.Query is from Commands for Searching, Replacing and Substituting in Vi Editor topic in section The Vi Editor of Unix

Answer»

The correct ANSWER is (b) False

The explanation is: There are many flags like ‘g’, ‘gc’ which are used as flags. For EXAMPLE, when we left the flag FIELD empty in the FOLLOWING command:

6.

Which of the following commands can be used to replace ‘professor’ with ‘director’ throughout the whole file?(a) 1,$s/professor/director/g(b) %s/professor/director/g(c) 1,$s/professor/director(d) 1,$s/professor/director/g and %s/professor/director/gThis question was posed to me during an online exam.This is a very interesting question from Commands for Searching, Replacing and Substituting in Vi Editor topic in division The Vi Editor of Unix

Answer»

The correct option is (d) 1,$s/professor/director/G and %s/professor/director/g

The explanation: We can replace 1,$ with %. It will WORK same as 1,$. ‘g’ flag is USED for GLOBAL replacement.

7.

The target pattern is optional.(a) True(b) FalseThe question was posed to me by my college director while I was bunking the class.This intriguing question originated from Commands for Searching, Replacing and Substituting in Vi Editor in division The Vi Editor of Unix

Answer»

Correct ANSWER is (a) True

To EXPLAIN: The target pattern specified is optional while performing the substitution. If the target pattern is LEFT out, then instances of the SOURCE pattern in all addressed lines are DELETED.

8.

Which of the following symbol is used for substitution command?(a) n(b) N(c) s(d) SThis question was addressed to me in examination.I'm obligated to ask this question of Commands for Searching, Replacing and Substituting in Vi Editor topic in portion The Vi Editor of Unix

Answer» RIGHT option is (C) s

Explanation: For replacing a pattern with ANOTHER pattern we use SUBSTITUTION COMMAND which is represented by ‘s’.
9.

Which command is used for repeating the search in the same direction?(a) n(b) N(c) nn(d) NNI had been asked this question in an online interview.The above asked question is from Commands for Searching, Replacing and Substituting in Vi Editor topic in chapter The Vi Editor of Unix

Answer»

Correct choice is (a) n

The best explanation: For REPEATING a search in the same direction in which the PREVIOUS search was made with EITHER / or ? we can use ‘n’ command. In this way, we can press ‘n’ repeatedly to scan all instances of the PATTERN.

10.

Which command is used to reverse the direction of repeating the search?(a) n(b) N(c) nn(d) NNThe question was asked by my college director while I was bunking the class.This interesting question is from Commands for Searching, Replacing and Substituting in Vi Editor topic in section The Vi Editor of Unix

Answer»

The CORRECT choice is (b) N

For explanation: ‘N’ reverses the direction pursued by ‘n’, which MEANS that we can USE it to retrace our SEARCH path.

11.

Substitution command is an ex-mode command.(a) True(b) FalseThis question was posed to me in an online quiz.The above asked question is from Commands for Searching, Replacing and Substituting in Vi Editor topic in chapter The Vi Editor of Unix

Answer»

The correct option is (a) True

The best explanation: VI offers a POWERFUL feature, that is of substitution, which is achieved with the ex-mode substitute (s) COMMAND. It lets us replace a pattern in a FILE with some other pattern.

12.

____ searches for a first instance of a pattern in the backward direction.(a) /(b) %(c) &(d) ?The question was asked during an interview.The query is from Commands for Searching, Replacing and Substituting in Vi Editor topic in portion The Vi Editor of Unix

Answer»

Correct option is (d) ?

To elaborate: We can use ? symbol in COMMAND mode for searching a particular PATTERN in the BACKWARD direction.The search BEGINS backwards to position the cursor on the first instance of the word. For example, if we are looking for the string “print” then we use the following command:

13.

Which symbol is used for repeating the last command?(a) $(b) *(c) .(d) _I got this question during an interview.The question is from Editing Text in Vi Editor topic in division The Vi Editor of Unix

Answer»

The correct CHOICE is (c) .

For EXPLANATION: Using (.) operator, we can SIMPLY repeat the last command that was used. The principle behind repeat command is, use the actual command once and then repeat it at other PLACES with DOT (.) command.

14.

____ searches for a first instance of a pattern in forwarding direction.(a) /(b) %(c) &(d) ?I have been asked this question during an online interview.Origin of the question is Commands for Searching, Replacing and Substituting in Vi Editor topic in chapter The Vi Editor of Unix

Answer»

Right choice is (a) /

The best explanation: We can USE / symbol in command MODE for searching a particular pattern in forwarding direction.The search begins forward to POSITION the cursor on the first instance of the word. For EXAMPLE, if we are LOOKING for the string “print” then we can use the following command:

15.

Which of the following symbols are used for searching a pattern in vi?(a) /(b) ?(c) %(d) / and ?I have been asked this question during a job interview.The doubt is from Commands for Searching, Replacing and Substituting in Vi Editor in chapter The Vi Editor of Unix

Answer»

The CORRECT option is (d) / and ?

The best I can explain: vi is EXTREMELY strong in searching for a pattern. Searching can be made both in FORWARD and in REVERSE DIRECTIONS using / and ? respectively.

16.

’10u’ command will reverse our 10 last editing actions.(a) True(b) FalseI have been asked this question in exam.I want to ask this question from Editing Text in Vi Editor topic in chapter The Vi Editor of Unix

Answer»

Right CHOICE is (a) True

The EXPLANATION: We can UNDO multiple changes using ‘u’ command by PREFIXING repeat factor with command. For example,

17.

Which command is used to redo the changes made by the undo command?(a) ctrl-l(b) ctrl-r(c) ctrl-g(d) ctrl-fI have been asked this question in my homework.This intriguing question comes from Editing Text in Vi Editor topic in division The Vi Editor of Unix

Answer» CORRECT option is (b) ctrl-r

The best EXPLANATION: We can USE the control KEY (ctrl-r) to redo the changes which are made by the undo command.
18.

Which command will be used to join 4 lines with the current line?(a) 5J(b) 4J(c) 6J(d) 4jI had been asked this question by my college director while I was bunking the class.This interesting question is from Editing Text in Vi Editor in portion The Vi Editor of Unix

Answer»

The correct choice is (a) 5J

For explanation I WOULD say: JOIN COMMAND joins the current line with the following number of lines. For EXAMPLE,

19.

___ command allows us to undo a number of changes that have been made to a single line before moving away from that line.(a) u(b) U(c) dd(d) yyI have been asked this question during an online exam.Query is from Editing Text in Vi Editor topic in section The Vi Editor of Unix

Answer»

The correct option is (b) U

Best explanation: When a number of changes have to be made to a SINGLE line, VI allows us to discard all changes before you move away from the line. If the cursor has been MOVED to another line before INVOKING ‘U’, this command will not WORK.

20.

Which of the following undo a most recent single editing change?(a) u(b) U(c) uu(d) yyI had been asked this question in an online interview.This intriguing question originated from Editing Text in Vi Editor topic in portion The Vi Editor of Unix

Answer» CORRECT answer is (a) u

To explain: To reverse the last change you made to the BUFFER press the ‘u’ key. This will restore the state of the buffer by undoing the most recent action TAKEN.
21.

Which command is used for joining lines?(a) J(b) j(c) yy(d) jnThe question was posed to me in an online quiz.Question is taken from Editing Text in Vi Editor in section The Vi Editor of Unix

Answer» CORRECT choice is (a) J

The best I can explain: To join current LINE with the line(s) FOLLOWING it, we can use join (J) command. It just pulls up the following line by terminating the NEW line character between the current line and following line.
22.

We can use ‘yy’ command for copy and paste operation.(a) True(b) FalseThe question was posed to me in class test.This key question is from Editing Text in Vi Editor topic in portion The Vi Editor of Unix

Answer»

Correct ANSWER is (a) True

The best explanation: We can copy LINES using ‘YYCOMMAND and PASTE it at another location using ‘p’ or ‘P’ command.

23.

Which command is used for putting deleted lines or part of lines at a different location?(a) p and P(b) x(c) dd(d) yI have been asked this question in exam.My doubt is from Editing Text in Vi Editor in portion The Vi Editor of Unix

Answer»

The CORRECT choice is (a) P and P

Best EXPLANATION: Using ‘p’ and ‘P’ command we can put deleted text at a different location. For example, if we’d deleted a single character using ‘X’ then we can put that character at ANOTHER location by placing the cursor at that location and pressing ‘p’ or ‘P’.

24.

To copy 10 lines from the current cursor location, we can use _____(a) 10y(b) 10yy(c) yy10(d) 10xI had been asked this question during an online interview.Question is from Editing Text in Vi Editor in portion The Vi Editor of Unix

Answer»

The correct CHOICE is (b) 10yy

Easiest explanation: Since yanking is performed by the yy command HENCE to copy the current LINE and 9 lines below we can USE the command ’10yy’.

25.

Both ‘p’ and ‘P’ command puts text right/left or above/below on the basis of line deleted.(a) True(b) FalseThis question was posed to me during an interview for a job.The origin of the question is Editing Text in Vi Editor topic in chapter The Vi Editor of Unix

Answer»

Correct answer is (a) True

Explanation: If we’d deleted a PART of a LINE, then ‘p’ will PUT it to the right of the cursor and ‘P’ will put it to the LEFT of the cursor. SIMILARLY, if we’d deleted the entire line then ‘p’ will put it below the current cursor and ‘P’ will put it above the cursor.

26.

To copy (yank) lines in vi editor, we use ______ command.(a) dd(b) x(c) p(d) yyThis question was addressed to me in an international level competition.I want to ask this question from Editing Text in Vi Editor in division The Vi Editor of Unix

Answer»

The correct CHOICE is (d) yy

Easiest explanation: To copy lines in VI editor, we can use ‘yy’ command. It works similarly as ‘DD’ command. For example, to yank 5 lines from current cursor we can use the command ‘5yy’.

27.

Which of the following commands will be used to delete 6 lines from the current cursor location?(a) 6d(b) 6X(c) 6dd(d) 6xThis question was posed to me in my homework.My enquiry is from Editing Text in Vi Editor in division The Vi Editor of Unix

Answer» RIGHT answer is (C) 6dd

Best explanation: ‘dd’ command can be used with repeat factor to delete multiple LINES at a single TIME. 6dd will delete the current line and 5 lines below.
28.

Which of the following command is used to delete a single line?(a) dd(b) x(c) X(d) dI had been asked this question in homework.My question is taken from Editing Text in Vi Editor topic in division The Vi Editor of Unix

Answer»

Correct ANSWER is (a) DD

For explanation: We can delete ENTIRE LINES with ‘dd’ command. Just move the cursor ANYWHERE on the line and press ‘dd’ and the entire line will be deleted.

29.

Which command is used for deleting the character on the left of the cursor?(a) x(b) X(c) dd(d) dThe question was posed to me in a job interview.I need to ask this question from Editing Text in Vi Editor in portion The Vi Editor of Unix

Answer»

Correct answer is (B) X

Easiest explanation: For DELETING a single character, we can use ‘X’ command. It DELETES a single character but to the LEFT of the cursor.

30.

Which command is used for deleting a single character?(a) d(b) dd(c) x(d) wThis question was posed to me in my homework.My doubt is from Editing Text in Vi Editor in chapter The Vi Editor of Unix

Answer»

The correct answer is (c) x

The EXPLANATION is: The simplest text deletion is ACHIEVED using ‘x’ command. This command deletes the character under the CURSOR and then the text on the right SHIFTS TOWARDS the left to fill up space.

31.

Which key is used for deleting text?(a) d(b) y(c) k(d) fThis question was addressed to me during an interview.This intriguing question comes from Editing Text in Vi Editor topic in chapter The Vi Editor of Unix

Answer»

Correct CHOICE is (a) d

Explanation: ‘d’ is not a command but is used as ‘DD’ to delete entire LINES. For EXAMPLE, to a delete a line INVOKE the command mode and press dd and the entire line will be deleted.

32.

Copying is referred to as yanking in vi editor.(a) True(b) FalseThe question was asked during a job interview.My question is taken from Editing Text in Vi Editor topic in chapter The Vi Editor of Unix

Answer»

Correct ANSWER is (a) True

The EXPLANATION is: Copying text or characters is known as yanking in VI editor.

33.

Which of the following commands of ex-mode is equivalent to ‘G’ command in command mode?(a) : .(b) : $(c) : %(d) :wI got this question in my homework.Origin of the question is Navigation in Vi Editor topic in division The Vi Editor of Unix

Answer» RIGHT answer is (b) : $

Best EXPLANATION: ex-mode offers equivalent commands for moving between lines. ‘G’ COMMAND moves the cursor to end of the FILE which can also be achieved USING ‘: $’ command in ex-mode.
34.

Which key is used for absolute movement?(a) f(b) G(c) M(d) ctrl-gThis question was addressed to me during a job interview.This question is from Navigation in Vi Editor in chapter The Vi Editor of Unix

Answer»

Right option is (c) M

The best I can EXPLAIN: For absolute movement, we can use the ‘G’ command along with the prefix FACTOR to locate offending lines. For example,

35.

Which command is used to know the current line number?(a) ctrl-f(b) ctrl-b(c) ctrl-z(d) ctrl-gThe question was posed to me during an interview for a job.Enquiry is from Navigation in Vi Editor topic in division The Vi Editor of Unix

Answer»

Right option is (d) ctrl-g

Easy EXPLANATION: At any TIME, to know the CURRENT LINE number we can use ctrl-g.

36.

To navigate 20 pages forward, we can use ______ command.(a) 20 ctrl-b(b) 20 ctrl-d(c) 20 ctrl-u(d) 20 ctrl-fI have been asked this question in a national level competition.I'd like to ask this question from Navigation in Vi Editor in division The Vi Editor of Unix

Answer»

Right OPTION is (d) 20 ctrl-f

The explanation: To navigate through 20 pages simultaneously we can prefix the REPEAT factor with control KEYS.

37.

We can scroll halve page using control keys.(a) True(b) FalseI have been asked this question in an interview.I would like to ask this question from Navigation in Vi Editor in section The Vi Editor of Unix

Answer»

The CORRECT OPTION is (a) True

To explain: To scroll half a page we can use CONTROL KEYS LIKE ctrl-d and ctrl-u.

38.

Which of the following control keys will be used for scrolling one page forward?(a) ctrl-f(b) ctrl-b(c) ctrl-z(d) ctrl-vI had been asked this question during an interview.This key question is from Navigation in Vi Editor topic in portion The Vi Editor of Unix

Answer»

Correct answer is (a) ctrl-f

The explanation is: Faster NAVIGATION can be achieved in VI using CONTROL keys for scrolling text in the WINDOW page by page. Ctrl-b scrolls ONE page backwards.

39.

Which of the following commands will move the cursor to the end of line number 30 if the current position of the cursor is line number 01?(a) 30$(b) 30|(c) 30b(d) 30%I have been asked this question in an online quiz.Asked question is from Navigation in Vi Editor in section The Vi Editor of Unix

Answer»

Correct answer is (a) 30$

The best EXPLANATION: We can prefix the repeat factor while WORKING with LINE extreme NAVIGATION commands.

40.

____ command moves the cursor to the end of next line.(a) 0(b) |(c) %(d) $This question was posed to me in examination.Query is from Navigation in Vi Editor topic in division The Vi Editor of Unix

Answer»

The correct CHOICE is (d) $

To explain: ‘$’ COMMAND is used to navigate the cursor to the END of next line. This SYMBOL is also used in ex-mode to represent the LAST line.

41.

Which command is used for moving the cursor to the line extreme?(a) |, 0(b) &(c) %(d) LThe question was asked in an interview.My question is based upon Navigation in Vi Editor topic in section The Vi Editor of Unix

Answer» RIGHT choice is (a) |, 0

Explanation: For moving the cursor to the beginning or end of the line we can USE line extreme navigation COMMANDS (0,| and $). ‘|’ or ‘0’ moves the cursor to the first CHARACTER of a line.
42.

Using ‘w’ command we can _____________(a) move back to the beginning of the word(b) move forward to the end of the word(c) move forward to the beginning of the word(d) move back to the end of the wordI have been asked this question in final exam.My question comes from Navigation in Vi Editor in portion The Vi Editor of Unix

Answer»

Correct choice is (c) MOVE forward to the beginning of the word

Easiest explanation: We can USEW’ command to move forward to the beginning of the word. To do so, simply press ‘w’ once for performing navigation a single time.

43.

We can prefix repeat factor with word navigation commands.(a) True(b) FalseThis question was posed to me in unit test.I'm obligated to ask this question of Navigation in Vi Editor topic in division The Vi Editor of Unix

Answer»

The CORRECT option is (a) True

Explanation: We can PREFIX repeat factor with word navigation COMMANDS for ease of navigation. For example, 5w TAKES the cursor 5 words forward while 5b takes the cursor 5 words backwards.

44.

Using ‘e’ commandwe can _____________(a) move back to the beginning of the word(b) move forward to the end of the word(c) move forward to the beginning of the word(d) move back to the end of the wordI got this question in an online quiz.Origin of the question is Navigation in Vi Editor topic in section The Vi Editor of Unix

Answer»

Correct answer is (b) move forward to the end of the word

For explanation I WOULD SAY: We can use ‘E’ command to move forward to the end of the word. To do so, simply PRESS ‘e’ once for performing navigation a single time.

45.

Using ‘b’ commandwe can _____________(a) move back to the beginning of the word(b) move forward to the end ofthe word(c) move forward to the beginning ofthe word(d) move back to the end ofthe wordThe question was posed to me in quiz.The question is from Navigation in Vi Editor topic in division The Vi Editor of Unix

Answer»

Right answer is (a) move back to the BEGINNING of the word

To explain: We can use ‘b’ command to move back to the beginning of the word. To do so, SIMPLY press ‘b’ once for performing NAVIGATION a SINGLE time.

46.

We can perform word navigation in vi editor.(a) True(b) FalseThis question was addressed to me in final exam.My doubt is from Navigation in Vi Editor topic in chapter The Vi Editor of Unix

Answer»

The correct option is (a) True

Best explanation: MOVING character by character is not always enough so we can perform NAVIGATION word by word by using word navigation commands (B, e and W).

47.

Which one of the following command is invalid?(a) 20h(b) 5l(c) 4k(d) 3dThis question was addressed to me in unit test.The doubt is from Navigation in Vi Editor topic in division The Vi Editor of Unix

Answer»

The correct answer is (d) 3D

To elaborate: All the above commands EXCEPT 3d are NAVIGATION commands with prefixed repeat FACTOR.

48.

We can prefix the repeat factor with navigation keys (h, j, k and l).(a) True(b) FalseThis question was addressed to me in an interview for internship.Asked question is from Navigation in Vi Editor in section The Vi Editor of Unix

Answer»

Right choice is (a) True

For explanation: The REPEAT factor can be USED as a command prefix with all these FOUR commands. For example, to MOVE 20 characters to the right, we can USE ’20l’.

49.

Which one of the following keys are used to moving cursor rightwards along a line?(a) k(b) h(c) l(d) jI got this question in an online quiz.Query is from Navigation in Vi Editor topic in division The Vi Editor of Unix

Answer» RIGHT choice is (c) l

Easy explanation: For moving the CURSOR TOWARDS the right, we can use ‘l’ KEY.
50.

Which of the following keys is used to moving cursor leftwards along a line?(a) k(b) h(c) l(d) jThe question was posed to me in homework.I'm obligated to ask this question of Navigation in Vi Editor topic in division The Vi Editor of Unix

Answer» RIGHT answer is (b) h

Best EXPLANATION: For moving the cursor TOWARDS left, we can use ‘h’ KEY.