提问人:myol 提问时间:11/9/2023 最后编辑:myol 更新时间:11/9/2023 访问量:11
具有多个句点的 Glob 匹配文件路径
Glob matching file paths with multiple periods
问:
我正在尝试使用 glob 匹配文件名中具有多个句点的文件,包括扩展名。
ls /path/to/my/example.file.txt
ls /path/to/my/file.txt
ls /path/to/my-example.file.txt
ls /path/to/my.example.file.txt
ls /path/which/is/longer/to/my/example.file.txt
ls /path/which/is/even/longer/to/my/example.file.txt
我尝试使用以下内容;
ls /path/**/*.txt
但我只得到了一些比赛。如果文件有多个句点,则似乎不匹配。*.txt
我尝试了如下方法,但它并没有真正起作用,我想有一种更干净的方法可以做到这一点。
ls /path/**/[a-zA-Z0-9\.]*.txt
ls /path/**/**.txt
ls /path/**/*.*.txt # Doesn't work for files with a single period
仅举例来说,使用 和 路径。ls
我对底层程序可能无法正确实现通配的想法持开放态度。
答:
0赞
myol
11/9/2023
#1
我正在将 glob 传递给另一个程序,并且在被程序读取之前,它在 bash 中被扩展
program '/path/**/*.txt' # works as expected
评论