Regular Expressions for file name matching

前端 未结 6 1267
自闭症患者
自闭症患者 2020-12-30 06:18

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.

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-30 06:25

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

    for file in *.log *.txt
    

提交回复
热议问题