Tag: unix

Questions Related to unix

  1. ^pat

  2. $pat

  3. pat$

  4. pat^


Correct Option: A
Explanation:

To match the pattern "pat" at the beginning of a line using the grep command, the symbol ^ will be used.

Now let's go through each option and explain why it is right or wrong:

A. ^pat: This option is correct. The ^ symbol in a regular expression is used to match the pattern at the beginning of a line. Therefore, ^pat will match the pattern "pat" at the beginning of a line.

B. $pat: This option is incorrect. The $ symbol in a regular expression is used to match the pattern at the end of a line. Therefore, $pat will match the pattern "pat" at the end of a line, not at the beginning.

C. pat$: This option is incorrect. The $ symbol in a regular expression is used to match the pattern at the end of a line. Therefore, pat$ will match the pattern "pat" at the end of a line, not at the beginning.

D. pat^: This option is incorrect. The symbol ^ does not have any special meaning when it appears after the pattern. Therefore, pat^ will match the literal string "pat^" rather than the pattern "pat" at the beginning of a line.

The Answer is: A. ^pat

Which command is used to change protection mode of files starting with the string emp and ending with 1,2, or 3?

  1. chmod u x emp[l-3]

  2. chmod 777 emp*

  3. chmod u r ??? emp

  4. chmod 222 emp?


Correct Option: A
  1. wc infile >newfile

  2. wc newfile

  3. wc infile - newfile

  4. wc infile | newfile


Correct Option: A
  1. chmod go r note

  2. chmod go rw note

  3. chmod go-x note

  4. chmod go-r, 4-x note


Correct Option: D