Bash bracket expansion: How to match all files names with a number?

蓝咒 提交于 2019-12-11 10:05:48

问题


I want to match all filenames in a directory that are like this:

h1.txt, h2.txt, h12.txt, h3.txt

If I do

echo h[[:digit:]].txt

I get

h1.txt, h2.txt, h3.txt

so it matches all the files I want, except h12.txt, because it has two digits instead of one. Is there an expansion for one or more digits?


回答1:


Figured it out!

echo h+([[:digit:]]).txt


来源:https://stackoverflow.com/questions/35433926/bash-bracket-expansion-how-to-match-all-files-names-with-a-number

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!