普通防爆pressions文件名匹配 [英] Regular Expressions for file name matching

查看:129
本文介绍了普通防爆pressions文件名匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在bash中,一个人如何匹配正前pression与对文件名多重标准?
例如,我想匹配所有.txt或.LOG结尾的文件。

In Bash, how does one match a regular expression with multiple criteria against a file name? For example, I'd like to match against all the files with .txt or .log endings.

我知道如何搭配一种类型的标准:

I know how to match one type of criteria:

for file in *.log
do
        echo "${file}"
done

什么为逻辑或匹配的标准两种以上?语法

What's the syntax for a logical or to match two or more types of criteria?

推荐答案

做到这一点,你会调用 LS同样的方式。您可以指定多个通配符一前一后:

Do it the same way you'd invoke ls. You can specify multiple wildcards one after the other:

for file in *.log *.txt

这篇关于普通防爆pressions文件名匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆