How do I break up an extremely long string literal in bash?

后端 未结 6 1109
独厮守ぢ
独厮守ぢ 2021-01-30 10:21

I would like to embed a long command like this in a bash script:

mycommand \\
    --server myserver \\
    --filename extremely/long/file/name/that/i/would/like/         


        
6条回答
  •  隐瞒了意图╮
    2021-01-30 11:04

    One can also use an array variable

    file=(extremely/long/file/name
        /that/i/would/like/to/be/able/to/break
        /up/if/possible)
    IFS=''
    
    echo mycommand\
        --server myserver\
        --filename "${file[*]}"\
        --flag flag
    

提交回复
热议问题