Definisco una breve funzione strcat nella parte superiore del mio script bash e utilizzo un'invocazione inline per suddividere le cose. A volte lo preferisco all'utilizzo di una variabile separata perché posso definire il lungo letterale in linea con l'invocazione del comando.
function strcat() {
  local IFS=""
  echo -n "$*"
}
mycommand \
  --server myserver \
  --filename "$(strcat \
      extremely/long/file/name/ \
      that/i/would/like/to/be/able/to/break/ \
      up/if/possible)" \
  --otherflag \
  --anotherflag \
Mi piace anche questo approccio per quando devo inserire un lungo CSV di valori come parametro flag perché posso usarlo per evitare di digitare la virgola tra i valori:
function strjoin() {
  local IFS="$1"
  shift
  echo -n "$*"
}
csv_args=(
  foo=hello
  bar=world
  "this=arg  has  spaces  in  it"
)
mycommand \
  --server myserver \
  --csv_args "$(strjoin , "${csv_args[@]}")" \
  --otherflag \
  --anotherflag \
Che equivale a
mycommand \
  --server myserver \
  --csv_args "foo=hello,bar=world,this=arg  has  spaces  in  it" \
  --otherflag \
  --anotherflag \
Puoi usare una variabile :
file=extremely/long/file/name
file+=/that/i/would/like/to/be/able/to/break
file+=/up/if/possible
mycommand\
    --server myserver\
    --filename $file\
    --flag flag
Si può anche usare una variabile array
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
 È un un po' di hack, ma funziona:
mycommand \
    --server myserver \
    --filename "extremely/long/file/name/"`
               `"that/i/would/like/to/be/able/to/break/"`
               `"up/if/possible" \
    --otherflag \
    --anotherflag
 Bash concatena valori letterali stringa adiacenti, quindi ne approfittiamo. Ad esempio, echo "hi" "there" stampa hi there mentre echo "hi""there" stampa hithere .
Sfrutta anche l'operatore di apice inverso e il fatto che un gruppo di spazi non valga nulla.