The source code to get the list of filenames matching the specified wild card pattern is given below. The given program is compiled and executed on Windows 10 Operating System successfully.
# Ruby program to get the list of filenames
# matching the specified wild card pattern
filenames = Dir::entries("MyDir");
puts "All Filenames: ",filenames;
filenames = Dir::glob("MyDir/Sample*");
puts "\nFile names: ",filenames;
Program/Source Code:
The source code to get the list of filenames matching the specified wild card pattern is given below. The given program is compiled and executed on Windows 10 Operating System successfully.
Output:
Explanation:
In the above program, we get the list of filenames using the Dir::glob() method with a specified wild card pattern and print the result.
need an explanation for this answer? contact us directly to get an explanation for this answer