Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
52
rated 0 times [  52] [ 0]  / answers: 1 / hits: 49853  / 1 Year ago, fri, april 28, 2023, 1:42:36

I have a text file with lots of package names.



package1
package2

# comment
# installing package3 because it was needed for...
package 3

package 4


How can I mass install all packages inside the text file without removing the comments?


More From » apt

 Answers
6

Something along these lines ought to do the trick.



apt-get install $(grep -vE "^s*#" filename  | tr "
" " ")


The $(something) construction runs the something command, inserting its output in the command line.



The grep command will exclude any line beginning with a #, optionally allowing for whitespace before it. Then the tr command replaces newlines with spaces.


[#32781] Saturday, April 29, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
fulpu

Total Points: 116
Total Questions: 118
Total Answers: 104

Location: Solomon Islands
Member since Fri, Oct 8, 2021
3 Years ago
fulpu questions
Fri, Apr 1, 22, 08:36, 2 Years ago
Wed, Mar 16, 22, 15:25, 2 Years ago
Wed, Aug 24, 22, 22:59, 2 Years ago
Tue, Dec 20, 22, 22:33, 1 Year ago
;