Exam 010-160 All QuestionsBrowse all questions from this exam
Question 22

A directory contains the following files:

What would be the output of the following shell script?

for file in *.txt

    Correct Answer: E

    The provided shell script uses a for loop to iterate over all files in the directory that match the pattern "*.txt". In the directory, there are two files that match this pattern: a.txt and b.txt. The script will print the name of each matching file on a new line. Therefore, the output will include both "a.txt" and "b.txt". The correct answer, reflecting both file names with the correct formatting, is option E.

Discussion
Nvidia

I dont understand this question

IanBilbo12

I believe the shell script calls to echo out the files. However, .cav IS NOT a valid file format, so it doesn't get called??? Anyone who knows for real, please chime in.

NivC

It is about the wildcard * which means that all files that end with ".txt" are valid, will show in the output the full file name.

rbishunOption: A

#!/bin/bash for file in *.txt do echo $file done #Output: *.txt

JarnBarn

The formating of this question is bonkers.

VovanichOption: E

E. a. txt b. txt

linvidiaOption: E

Output: a.txt b.txt

TraianOption: E

Tested myself. Should be "E" the right answer.

quiquisimoOption: A

i think it's A because * is a meta-character, so the "for" will search for every pattern that ends with .txt

quiquisimo

sorry, it's E.

66cf1d7Option: E

I tested the script myself. If there were no files named that way it iterates through the literal string *.txt and prints each character.

rbishunOption: E

E is the correct answer - script returns same as: ls *.txt