Is there an easy way to set nullglob for one glob

前端 未结 5 1207
谎友^
谎友^ 2021-02-03 23:22

In bash, if you do this:

mkdir /tmp/empty
array=(/tmp/empty/*)

you find that array now has one element, \"/tmp/empty/*\"

5条回答
  •  萌比男神i
    2021-02-03 23:59

    This is the simplest solution I've found:

    For example, to expand the literal **/*.mp3 into a glob for only a particular variable, you can use

    VAR=**/*.mp3(N)
    

    Source: https://unix.stackexchange.com/a/204944/56160

提交回复
热议问题