How to use Bash substitution in a variable declaration

前端 未结 1 763
感动是毒
感动是毒 2020-12-17 00:40

I try to declare a variable x with all chars from a..x. On the command line (bash), substitution of a..x works w/o any ticks.

相关标签:
1条回答
  • 2020-12-17 00:44

    You can also use set (but be sure to save positional parameters if you still need them):

    set {a..x}
    x="$@"
    

    For arrays, brace expansion works directly:

    disks=( {a..x} )
    
    0 讨论(0)
提交回复
热议问题