globbing:
句法为 glob pattern;
pattern为其使用的文件名模式匹配,?代表单个字符,*代表任何数目的字符,若pattern如给出具体的路径名,则其路径名也可返回,
代码为:
其运行结果为:
若pattern不给出路径名,则使用当前的文件夹路径,但不返回,代码为:
运行结果为:
目录句柄
先使用opendir打开目的目录的句柄,再使用readdir读取此目录文件列表,可以使用grep函数配合正则表达式来选择我们需要的文件名,代码如下:
其结果如下,得到glob一样的结果。