How to assign a glob expression to a variable in a Bash script?

后端 未结 8 1456
渐次进展
渐次进展 2020-12-08 02:21

When the following two lines of code are executed in a bash script, \"ls\" complains that the files don\'t exist:

dirs=/content/{dev01,dev02}
ls -l $dirs
         


        
8条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 02:53

    Here is an excellent discussion of what you are trying to do.

    The short answer is that you want an array:

    dirs=(/content/{dev01,dev01})
    

    But what you do with the results can get more complex than what you were aiming for I think.

提交回复
热议问题