Regular Expressions for file name matching

前端 未结 6 1230
自闭症患者
自闭症患者 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:30

    You simply add the other conditions to the end:

    for VARIABLE in 1 2 3 4 5 .. N
    do
        command1
        command2
        commandN
    done
    

    So in your case:

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

提交回复
热议问题