LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-19-2023, 04:09 PM   #1
debianfella
LQ Newbie
 
Registered: Jul 2023
Posts: 15

Rep: Reputation: 0
How to install packages in a multilined fashion?


I have the problem that I have a long liner command and it's too long for me in one line. The command is basically installing packages:

Code:
apt install pack_1 pack_2 pack_3 pack_4 pack_5 ...
I have tried to do this:

Code:
apt install \
pack_1 \
pack_2 \
pack_3 \
pack_4 \
pack_5 \
...
Quote:
E: Unsupported file / given on commandline
How to install packages in a multilined fashion?

Last edited by debianfella; 07-19-2023 at 05:44 PM.
 
Old 07-19-2023, 05:52 PM   #2
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
One may easily do that with a for loop.
for pkg in pack1 \
pack2 pack3 \
pack4 pack5
do
apt install pkg
done
 
Old 07-19-2023, 09:30 PM   #3
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,159

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
#install using package name separated by space
sudo apt install vim git nano

# Install the packages listed in the file packages.txt, just like python -r requirements.txt
sudo apt install -f packages.txt

or do: apt install -y package1; apt install -y package2; apt install -y package3; etc...

Goodluck!
 
Old 07-19-2023, 11:41 PM   #4
mrmazda
LQ Guru
 
Registered: Aug 2016
Location: SE USA
Distribution: openSUSE 24/7; Debian, Knoppix, Mageia, Fedora, others
Posts: 5,829
Blog Entries: 1

Rep: Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069
You did leave the \ off of the last line, didn't you?
 
Old 07-20-2023, 03:49 AM   #5
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,159

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Lightbulb

Quote:
Originally Posted by mrmazda View Post
You did leave the \ off of the last line, didn't you?
yeah indeed
Quote:
" \ "
is looking for continuation... good catch

Last edited by JJJCR; 07-20-2023 at 03:49 AM. Reason: edit
 
Old 07-20-2023, 10:22 AM   #6
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,616

Rep: Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554
Quote:
Originally Posted by debianfella View Post
I have tried to do this:

Code:
apt install \
pack_1 \
pack_2 \
pack_3 \
pack_4 \
pack_5 \
...
No, you did not, because the error message you received was:
Code:
E: Unsupported file / given on commandline
That's a forward-slash, not a backslash.

It occurs when one includes a forward-slash in the "apt install" command, because APT can accept both package names and file names, but the filesystem root is not a supported file.

(And I repeat my advice that mass installing the hundreds of packages that contain "php" in their name is a really bad idea.)


Last edited by boughtonp; 07-20-2023 at 10:26 AM.
 
Old 07-20-2023, 10:48 AM   #7
debianfella
LQ Newbie
 
Registered: Jul 2023
Posts: 15

Original Poster
Rep: Reputation: 0
I think I have confused one error with another, because:

Code:
apt install \
pack_1
Quote:
+ apt install pack_1
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package pack_1
Anyway, I like the idea of doing this with a for loop.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Managing saved html files in easily queryable fashion? bramadams Linux - Software 2 08-01-2004 06:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration