Issue
System is Debian 10 with xfce 4.
I usually use \
at the end of line when bash command has multi parameters.Then I tried:
pc@server:~$ apt install -y ./code_1.54.1-1614898113_amd64.deb\
./veracrypt-1.24-Update7-Debian-10-amd64.deb\
./bcompare-4.3.7.25118_amd64.deb\
./dbeaver-ce_21.1.0_amd64_a0667a.deb\
./rstudio-1.4.1106-aqmd64.deb\
But I didn't get what I want. I know it's ok to use
seperate parameters,like:
pc@server:~$ apt install -y ./code_1.54.1-1614898113_amd64.deb ./veracrypt-1.24-Update7-Debian-10-amd64.deb ./bcompare-4.3.7.25118_amd64.deb ./dbeaver-ce_21.1.0_amd64_a0667a.deb ./rstudio-1.4.1106-aqmd64.deb
Is there any way to set parameters one per line when using bash apt install
command?
Solution
What you have should work, with 2 caveats. The backslash must immediately precede the \n
, and you probably want to omit the backslash on the last line. eg:
$ cat a.sh
#!/bin/bash
for x; do echo arg: "$x"; done
$ ./a.sh foo\
> bar\
> baz\
>
arg: foo
arg: bar
arg: baz
Note that by retaining the backslash on the last line in the above example, an additional (unescaped) newline is required to terminate the command. Also note that the leading whitespace on subsequent lines is necessary, as the shell will literally ignore the escaped newline and merge the two arguments if there is no leading whitespace. eg:
$ ./a.sh foo\
> bar \
> baz
arg: foobar
arg: baz
Answered By - William Pursell