ExamVeda
Login
Home
1
Which symbol will be used with grep command to match the pattern pat at the beginning of a line?
Discuss
Answer & Solution
Answer: Option A
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.
2
Which command is used to sort the lines of data in a file in reverse order
Discuss
Answer & Solution
Answer: Option D
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.
3
Which command is used to display the top of the file?
Discuss
Answer & Solution
Answer: Option B
Solution:
In Unix, the head command is used to display the top part of a file. It prints the first 10 lines of the specified file by default. If you want to display a different number of lines, you can specify it using the -n option followed by the number of lines you want to display.
So, head is the correct command to display the top of a file.
4
Which command is used to copy all files having the string chap and any two characters after that to the progs directory?
Discuss
Answer & Solution
Answer: Option A
Solution:
In Unix, the cp command is used to copy files or directories. The pattern chap?? matches files with the string chap followed by any two characters. When followed by progs, it indicates that all files matching this pattern should be copied to the progs directory.
So, cp chap?? progs is the correct command to copy all files having the string chap and any two characters after that to the progs directory.
5
Which command is used to change protection mode of files starting with the string emp and ending with 1,2, or 3?
Discuss
Answer & Solution
Answer: Option A
Solution:
In Unix, the chmod command is used to change the permissions or protection mode of files or directories. The pattern emp[1-3] matches files starting with the string emp and ending with 1, 2, or 3.
By adding u+x to the chmod command, it grants execute permission to the owner of the file.
So, chmod u+x emp[1-3] is the correct command to change the protection mode of files starting with the string emp and ending with 1, 2, or 3.
6
Which command is used to remove a directory?
Discuss
Answer & Solution
Answer: Option B
Solution:
In Unix, the rmdir command is used to remove or delete a directory. It is specifically designed to remove directories and will only work if the directory is empty. If the directory contains any files or subdirectories, rmdir will not remove it and will generate an error message.
So, rmdir is the correct command to remove a directory.
7
Which of the following keys is used to replace a single character with new text?
Discuss
Answer & Solution
Answer: Option B
Solution:
In Unix command line editors like vi or Vim, the s key is used in the command mode to replace a single character under the cursor with new text. After pressing s, you can enter the replacement text, and the character under the cursor will be replaced with it.
So, s is the correct key to replace a single character with new text.
8
Which command is used to extract specific columns from the file?
Discuss
Answer & Solution
Answer: Option B
Solution:
In Unix, the cut command is used to extract specific columns from a file. It allows you to specify which columns you want to extract based on delimiters like space or tab.
So, cut is the correct command to extract specific columns from a file.
9
Which command sends the word count of the file infile to the newfile.
Discuss
Answer & Solution
Answer: Option A
Solution:
In Unix, the wc command is used to count words, lines, and characters in a file. The > symbol is used for output redirection, which means that the output of the command preceding it will be written to the specified file.
So, wc infile > newfile is the correct command to send the word count of the file infile to the newfile.
10
Which command is used to remove the read permission of the file 'note' from both the group and others?
Discuss
Answer & Solution
Answer: Option D
Solution:
In Unix, the chmod command is used to change the permissions of a file. Here, go-r specifies that read permission should be removed for both the group (g) and others (o).
So, chmod go-r note is the correct command to remove the read permission of the file 'note' from both the group and others.