简体   繁体   中英

How do I expand both the variable and the wildcard in a bash string?

I want to store in the TEMP variable the result of the following command:

TEMP="$(ls $dest_dir.*)"

The issue here is that only the variable is expanded, not the * wildcard. What I get from the expansion is:

dir_01.*

where dir_01 is the value in dest_dir. And that makes the ls command to fail.

How can I have the wildcard expanded as well?

try this:

TEMP=$(ls ${dest_dir}.*)

As others noted though, parsing ls output is generally not a good idea..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM