LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Redirecting text from a file into a command (https://www.linuxquestions.org/questions/linux-newbie-8/redirecting-text-from-a-file-into-a-command-739735/)

simplified 07-13-2009 08:46 AM

Redirecting text from a file into a command
 
Hi

I don't really know what I'm doing wrong here, but what I'm essentially trying to do is to get a list of packages into the command "apt-get install" but I can't seem to get it to work. The text file in question I have filtered out a list of all the installed packages on my system so that (heaven forbid) I lose my machine I can recover it quickly from a base install. I've tried this two ways:

Code:

$ sudo apt-get install < ./packages.txt
...so I then tried it this way:

Code:

cat ./packages.txt | sudo apt-get install
The file "packages.txt" is just a text file and has a package name on each line... here's the output from the first ten lines to give you an idea (it's quite a long file...!)

Code:

acl
acpi-support
acpid
adduser
akregator
alsa-base
alsa-utils
amarok
amarok-common
anacron

I'm using Kubuntu 9.04 on x64... not that this is really relelvant to this issue :D

I know this is a pretty lame question to ask, but I've tried fixing it myself and can't get anywhere...

ECRocker 07-13-2009 08:51 AM

I'm installing Apt now to test it out, but at first glance you might want to try > instead of <.

simplified 07-13-2009 08:56 AM

Thanks for looking at it - if you use the code:

Code:

$ cat ./packages.txt > sudo apt-get install
...this (as I suspected it would) basically copies the file packages.txt into a new file called sudo and the following errors are seen:

Code:

$ cat ./test.txt > sudo apt-get install
cat: apt-get: No such file or directory
cat: install: No such file or directory

Thanks for trying though :D

ECRocker 07-13-2009 09:00 AM

No, I mean:

Code:

sudo apt-get install > ./packages.txt
and instead of "install", isn't there a "list" function?

I've got APT, now I've got to update my list.

repo 07-13-2009 09:04 AM

Try
Code:

apt-get install $(cat <textfile>)
the names need to be in one line in the file
in your case try
Code:

aptitude install $(cat <textfile>)

tredegar 07-13-2009 09:12 AM

See here:
http://www.linuxquestions.org/questi...79#post2905379


All times are GMT -5. The time now is 08:09 PM.