Unix - Study Mode

[#451] For adding a new user to the system, we have to use . . . . . . . . command.
Correct Answer

(B) useradd

[#452] print statement is necessary for printing a line.
Correct Answer

(B) False

[#453] . . . . . . . . searches for a first instance of a pattern in the backward direction.
Correct Answer

(D) ?

[#454] Which symbol will be used with grep command to match the pattern pat at the beginning of a line?
Correct Answer

(A) ^pat

Explanation

Solution: In Unix, when using the grep command, the caret (^) symbol is used to match patterns at the beginning of a line . So, if you use ^pat with grep , it will match all the lines that start with the pattern "pat" . The caret (^) is called a metacharacter in regular expressions and it anchors the search pattern to the beginning of a line . When you use ^pat , grep will only return lines where the pattern "pat" occurs at the beginning of the line . This means that if "pat" occurs anywhere else in the line (not at the beginning), it won't be considered a match. So, to summarize, ^pat is the correct option because it specifically instructs grep to find lines where "pat" appears at the very beginning.

[#455] Which command is used to sort the lines of data in a file in reverse order
Correct Answer

(D) sort -r

Explanation

Solution: In Unix, the sort command is used to sort the lines of data in a file. By adding the -r option to the sort command, you can sort the lines in reverse order . So, sort -r is the correct command to sort the lines of data in a file in reverse order.