InterviewSolution
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. |
Which command will be used for selecting lines 3 to 10 from emp.lst?(a) sed 3,10emp.lst(b) sed -n ‘3,10p’ emp.lst(c) sed -n ‘^,10p’ emp.lst(d) sed -n, 10pThis question was posed to me in an online quiz.My question is based upon sed command in division Filters using Regular Expressions of Unix |
|
Answer» The CORRECT answer is (b) sed -n ‘3,10p’ emp.lst |
|
| 2. |
Which shortcut does sed offer to replace the string Linux with Red hat Linux?(a) { }(b) ( )(c) ^^(d) &The question was posed to me in a job interview.My question is based upon sed command topic in portion Filters using Regular Expressions of Unix |
|
Answer» The correct answer is (d) & |
|
| 3. |
Which one of the following command will be used for adding two spaces before every line in emp.lst?(a) sed ‘s/^//’ emp.lst(b) sed ‘s / //’emp.lst(c) sed ‘s /$//’emp.lst(d) sed ‘s/$/I got this question in an interview.Origin of the question is sed command in division Filters using Regular Expressions of Unix |
|
Answer» CORRECT choice is (a) SED ‘s/^//’ emp.lst Easy EXPLANATION: The ^ symbol is used for prefixing some VALUE at the beginning of any line in the file. |
|
| 4. |
The interval regular expression uses the character _______(a) {(b) }(c) { and }(d) ( and )I had been asked this question in an internship interview.The doubt is from sed command topic in division Filters using Regular Expressions of Unix |
|
Answer» Right choice is (c) { and } |
|
| 5. |
Which of the following characters are used with sed as anchoring characters?(a) $(b) ^(c) %(d) $ and ^The question was asked in an interview for internship.I would like to ask this question from sed command topic in portion Filters using Regular Expressions of Unix |
|
Answer» Correct ANSWER is (d) $ and ^ |
|
| 6. |
To replace the string ‘director’ in the first five lines of file emp.lst with ‘manager’ we can use _____(a) sed‘s/director/manager/’ emp.lst(b) sed ‘1-5s/director/manager/’ emp.lst(c) sed ‘1,5s/director/manager/’ emp.lst(d) sed ‘15sThis question was addressed to me in an internship interview.I need to ask this question from sed command in portion Filters using Regular Expressions of Unix |
|
Answer» Right answer is (c) sed ‘1,5s/director/manager/’ emp.lst |
|
| 7. |
Basic regular expressions are divided into ______ categories.(a) 1(b) 3(c) 2(d) 5This question was addressed to me during a job interview.I'd like to ask this question from sed command in division Filters using Regular Expressions of Unix |
|
Answer» Correct ANSWER is (B) 3 |
|
| 8. |
Which one of the following command is used for replacing | with : globally?(a) sed‘s/|/:/’ emp.lst(b) sed ‘/|/:/’ emp.lst(c) sed‘s/|/:/g’ emp.lst(d) sed ‘s/I have been asked this question in a national level competition.I want to ask this question from sed command topic in portion Filters using Regular Expressions of Unix |
|
Answer» Right choice is (C) SED‘s/|/:/g’ emp.lst |
|
| 9. |
Which one of the following is the correct syntax for performing substitution using sed?(a) sed [address]s/expr1/ expr2(b) sed [address]s/expr1 expr2(c) sed [address]s/expr1/ expr2/ flags(d) sed [address]sI had been asked this question in an interview.This question is from sed command in portion Filters using Regular Expressions of Unix |
|
Answer» Right ANSWER is (C) sed [address]s/expr1/ expr2/ flags |
|
| 10. |
To select lines containing gupta and agarwal, which command will be used?(a) sed -n ‘/gupta/,/agarwal/p’emp.lst(b) sed -n ‘/gupta/agarwal/p’emp.lst(c) sed ‘/gupta | agarwal’p’ emp.lst(d) sed -nThis question was posed to me by my school principal while I was bunking the class.Question is from sed command in division Filters using Regular Expressions of Unix |
|
Answer» Correct answer is (a) SED -n ‘/gupta/,/agarwal/p’emp.lst |
|
| 11. |
sed can also perform the substitution.(a) True(b) FalseI have been asked this question in homework.My question is taken from sed command topic in portion Filters using Regular Expressions of Unix |
|
Answer» Right option is (a) True |
|
| 12. |
To write selected lines, ____ is used with sed.(a) i(b) n(c) w(d) pThe question was posed to me in examination.My question is taken from sed command in chapter Filters using Regular Expressions of Unix |
|
Answer» RIGHT answer is (C) w Easy EXPLANATION: For writing selected lines to a separate file irrespective of the way of addressing (RELATIVE or context), we can use w (write) command. For example, |
|
| 13. |
To perform context addressing, we have to enclose the pattern in ____(a) double quotes(b) single quotes(c) //(d) $$I had been asked this question during an online exam.This interesting question is from sed command topic in division Filters using Regular Expressions of Unix |
|
Answer» The correct CHOICE is (C) // |
|
| 14. |
____ option is used for taking instructions from a file.(a) -f(b) -e(c) -i(d) -nI had been asked this question in a job interview.Question is taken from sed command in division Filters using Regular Expressions of Unix |
|
Answer» RIGHT option is (a) -f Explanation: SED COMMAND is QUITE liberal and it provides a great freedom in using and REPEATING options. We can use the -f option to direct sed to take its instructions from the file. |
|
| 15. |
The command $ sed -n ‘$p’ emp.lst will display the last line.(a) True(b) FalseI had been asked this question by my school principal while I was bunking the class.This intriguing question comes from sed command topic in portion Filters using Regular Expressions of Unix |
|
Answer» The correct option is (a) True |
|
| 16. |
Which option is used with sed for using multiple instructions?(a) -f(b) -n(c) -e(d) –f and -eThis question was posed to me in exam.This is a very interesting question from sed command in section Filters using Regular Expressions of Unix |
|
Answer» Right ANSWER is (d) –f and -e |
|
| 17. |
Which of the following command is used with sed for outputting as well as printing the selected lines?(a) q(b) n(c) p(d) iI have been asked this question in quiz.My query is from sed command topic in chapter Filters using Regular Expressions of Unix |
|
Answer» The CORRECT choice is (c) p |
|
| 18. |
To suppress the behavior of ‘p’ command of sed, we use ____ option.(a) -q(b) -n(c) -i(d) -vThe question was posed to me by my college professor while I was bunking the class.Origin of the question is sed command topic in division Filters using Regular Expressions of Unix |
|
Answer» The CORRECT CHOICE is (b) -n |
|
| 19. |
Which one of the following command will be used for quitting after selecting 3 lines from file emp.lst?(a) sed -n 3 emp.lst(b) sed -i 1-3 emp.lst(c) sed ‘3q’ emp.lst(d) sed -nThis question was posed to me during an online exam.Enquiry is from sed command topic in chapter Filters using Regular Expressions of Unix |
|
Answer» Right CHOICE is (c) sed ‘3q’ emp.lst |
|
| 20. |
Which option is used when we want to use an ERE with grep command?(a) -e(b) -i(c) -E(d) -iI had been asked this question during an online exam.I want to ask this question from grep command in chapter Filters using Regular Expressions of Unix |
|
Answer» The correct option is (C) -E |
|
| 21. |
Which of the following commands is known as stream editor?(a) sed(b) grep(c) grep(d) trI had been asked this question in an internship interview.My question is based upon sed command topic in section Filters using Regular Expressions of Unix |
|
Answer» The correct answer is (a) sed |
|
| 22. |
Which of the following symbols are used for matching multiple patterns?(a) |(b) &(c) ( and )(d) | and ( and )This question was posed to me in class test.This key question is from grep command in chapter Filters using Regular Expressions of Unix |
|
Answer» RIGHT answer is (c) ( and ) The BEST explanation: The | SYMBOL is a delimiter of multiple PATTERNS. Using it, we can match multiple patterns. For example, to match GUPTA and agarwal we can use the following command: |
|
| 23. |
What is the correct syntax for using sed?(a) sed options file(s)(b) sed options ‘action’(c) sed options ‘address action’ file(s)(d) sed ‘action’ file(s)The question was posed to me in an interview for job.This is a very interesting question from sed command topic in portion Filters using Regular Expressions of Unix |
|
Answer» Right answer is (c) SED options ‘address ACTION’ file(s) |
|
| 24. |
Which of the following symbols are a set ofERE (extended regular expressions)?(a) +(b) –(c) ?(d) + and –I have been asked this question during an online interview.This key question is from grep command topic in chapter Filters using Regular Expressions of Unix |
|
Answer» Right ANSWER is (d) + and – |
|
| 25. |
Which symbol is used for matching a single character?(a) *(b) .(c) &(d) %The question was asked in examination.The question is from grep command in chapter Filters using Regular Expressions of Unix |
|
Answer» The CORRECT choice is (b) . |
|
| 26. |
Which of the following symbols are used for matching a pattern at specified locations?(a) *(b) ^(c) $(d) ^ and $This question was posed to me in an interview for internship.My enquiry is from grep command topic in chapter Filters using Regular Expressions of Unix |
|
Answer» The correct option is (d) ^ and $ |
|
| 27. |
Which of the following symbol is used for matching the immediately preceding character?(a) *(b) $(c) [ ](d) %I had been asked this question during an interview.My question is based upon grep command in chapter Filters using Regular Expressions of Unix |
|
Answer» The correct answer is (a) * |
|
| 28. |
Character class is used for matching a group of characters enclosed within a pair of _____(a) ( )(b) “ “(c) [ ](d) { }This question was addressed to me at a job interview.The above asked question is from grep command topic in division Filters using Regular Expressions of Unix |
|
Answer» Correct option is (C) [ ] |
|
| 29. |
grep command supports both extended and regular expressions.(a) True(b) FalseThe question was asked by my college professor while I was bunking the class.My enquiry is from grep command topic in section Filters using Regular Expressions of Unix |
|
Answer» RIGHT ANSWER is (a) True The best explanation: grep command supports both CATEGORIES of regular expressions. It supports basic regular expression by default and extended regular expression with -E option. |
|
| 30. |
Which of the following is not a subset of BRE (basic regular expression) character subset?(a) *(b) .*(c) ^$(d) ch+I had been asked this question in examination.This interesting question is from grep command topic in division Filters using Regular Expressions of Unix |
|
Answer» Correct answer is (d) CH+ |
|
| 31. |
POSIX identifies regular expressions as belonging to ____ categories.(a) 3(b) 2(c) 4(d) 5This question was posed to me by my college director while I was bunking the class.Question is from grep command topic in division Filters using Regular Expressions of Unix |
|
Answer» Correct CHOICE is (b) 2 |
|
| 32. |
For taking patterns from a file, -f option is specified with grep command.(a) True(b) FalseI got this question in final exam.This question is from grep command topic in division Filters using Regular Expressions of Unix |
|
Answer» Correct answer is (a) True |
|
| 33. |
_____ option is used when we need to match multiple patterns in a single invocation of grep command?(a) -a(b) -e(c) -n(d) -iI have been asked this question in exam.I'm obligated to ask this question of grep command in chapter Filters using Regular Expressions of Unix |
|
Answer» CORRECT choice is (B) -e Explanation: grep provides an OPTION (-e) which is used when we want to match MULTIPLE patterns in a single invocation of the command. For example, the following command will match three agarwals: |
|
| 34. |
______ option counts the number of lines containing the pattern?(a) -c(b) -i(c) -e(d) -nThis question was addressed to me during an online exam.I'm obligated to ask this question of grep command in portion Filters using Regular Expressions of Unix |
|
Answer» CORRECT option is (a) -c Easy explanation: The -c option when used with grep COMMAND, COUNTS the number of LINES containing the PATTERN (which is not same as the number of occurrences of the pattern). For example, |
|
| 35. |
Which option is used with grep command for deleting lines?(a) -v(b) -e(c) -a(d) -iThe question was posed to me in exam.This intriguing question originated from grep command topic in chapter Filters using Regular Expressions of Unix |
|
Answer» The correct answer is (a) -v |
|
| 36. |
Which option displays only the filename containing the pattern?(a) -i(b) -n(c) -e(d) -lI had been asked this question during an interview.The query is from grep command in portion Filters using Regular Expressions of Unix |
|
Answer» Correct choice is (d) -l |
|
| 37. |
Which option is used for displaying the line numbers containing the pattern along with lines?(a) -v(b) -i(c) -e(d) -nThis question was posed to me in final exam.I'd like to ask this question from grep command topic in section Filters using Regular Expressions of Unix |
|
Answer» Correct option is (d) -n |
|
| 38. |
Which option is used with grep command for ignoring the case in pattern searching?(a) -a(b) -v(c) -i(d) -eI got this question in a national level competition.My question comes from grep command topic in portion Filters using Regular Expressions of Unix |
|
Answer» The correct answer is (c) -i |
|
| 39. |
If there are special characters in a pattern, then we’ve to enclose them in ______(a) single quotes(b) double quotes(c) without any quotes(d) all quotesThis question was addressed to me in an online quiz.Query is from grep command topic in portion Filters using Regular Expressions of Unix |
|
Answer» Right option is (b) double quotes |
|
| 40. |
grep command can be used for searching a pattern in more than one file.(a) True(b) FalseI got this question in a national level competition.My doubt stems from grep command topic in portion Filters using Regular Expressions of Unix |
|
Answer» CORRECT answer is (a) True Explanation: When we use grep command with multiple filenames, it displays the filename along with the OUTPUT. For example, when we SEARCH “director” in emp1.lstemp2.lst then the FOLLOWING result will be DISPLAYED, |
|
| 41. |
Which one of the following is the correct syntax for grep command?(a) grep options filename(s)(b) grep options pattern(c) grep pattern filename(d) grep options pattern filename(s)I had been asked this question in an international level competition.The doubt is from grep command topic in division Filters using Regular Expressions of Unix |
|
Answer» CORRECT option is (d) grep OPTIONS pattern filename(s) Explanation: grep COMMAND is USED to search a file for a pattern and display both matching and non-matching lines. The syntax for using grep command is: |
|
| 42. |
Which one of the following command will be used for searching “director” in emp.lst?(a) grep“director”(b) grep -v “director”emp.lst(c) grep-director emp.lst(d) grep“director” emp.lstI got this question during an internship interview.My question is taken from grep command topic in chapter Filters using Regular Expressions of Unix |
|
Answer» Correct choice is (d) grep“director” emp.lst |
|
| 43. |
When the pattern is not found in a file, grep command silently returns the prompt.(a) True(b) FalseThis question was posed to me in final exam.This is a very interesting question from grep command in chapter Filters using Regular Expressions of Unix |
|
Answer» RIGHT choice is (a) True The explanation: grep COMMAND is ALSO used as a filter for searching a pattern in a FILE. When the pattern is not found in the file, this command silently returns the prompt without displaying any diagnostic messages. For example, |
|
| 44. |
Which one of the following command is used for searching for a pattern in one or more file(s)?(a) cd(b) cp(c) paste(d) grepI have been asked this question in quiz.The question is from grep command topic in section Filters using Regular Expressions of Unix |
|
Answer» CORRECT OPTION is (d) grep The best I can explain: UNIX has a special FAMILY of commands for handling search REQUIREMENTS, and the principal member of this family is the grep command. This command scans its input for a pattern and displays the lines containing the pattern, the line numbers or filenames containing the pattern. |
|