How do you get all files with on the 3rd place an r, g or i?

  1. ls ?3[rgi]*

  2. ls [rgi]

  3. ls ??[rgi]*

  4. ls **[rgi]?


Correct Option: C
Explanation:

To answer this question, the user needs to know the basics of using wildcard characters in Linux. Wildcards are used to represent one or more characters in a filename or directory. In this case, we are looking for files that have an "r", "g", or "i" on the third place of their filename.

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

A. ls ?3[rgi]*: This option is incorrect because "?3" means to match any single character in the third position, and then we are looking for either "r", "g", or "i" as the next character. This would only match files that have a single character in the third position and then either "r", "g", or "i".

B. ls [rgi]: This option is incorrect because it would match any file that has "r", "g", or "i" anywhere in its filename. This would include files that have these characters on the third place as well as those that don't.

C. ls ??[rgi]*: This option is correct. The "??" matches any two characters in the filename, followed by either "r", "g", or "i", and then any number of other characters. This would match any file that has two characters before "r", "g", or "i" on the third place.

D. ls [rgi]?: This option is incorrect because "" means to match any number of directories recursively, and "[rgi]?" means to match any file that ends with either "r", "g", or "i", followed by any one character. This would match files that end with "r", "g", or "i", not those that have these characters on the third place.

Therefore, the correct answer is:

The Answer is: C. ls ??[rgi]*

Find more quizzes: