Variable containing multiple args with quotes in Bash

后端 未结 4 1416
渐次进展
渐次进展 2020-11-28 05:59

I generate a bash variable containing all my args and those args contain spaces. When I launch a command with those args - eg. ls $args - quotes are not correctly interprete

4条回答
  •  北海茫月
    2020-11-28 06:56

    You might consider using an array for the args, something like this:

    args=( "$f1" "$f2" )
    ls "${args[@]}"
    

    (The problem you're hitting at the moment is that once interpolation has happened there's no difference between intra- and inter- filename spaces.)

提交回复
热议问题