LinuxQuestions.org
Visit Jeremy's Blog.
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-13-2009, 09:46 AM   #1
simplified
Member
 
Registered: May 2007
Location: London, UK
Distribution: Kubuntu 9.04 x64 / Ubuntu Server 9.04 x64
Posts: 50

Rep: Reputation: 15
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

I know this is a pretty lame question to ask, but I've tried fixing it myself and can't get anywhere...
 
Old 07-13-2009, 09:51 AM   #2
ECRocker
Member
 
Registered: May 2007
Distribution: RHEL 5, Ubuntu 9.10, Fedora 12
Posts: 85

Rep: Reputation: 17
I'm installing Apt now to test it out, but at first glance you might want to try > instead of <.
 
Old 07-13-2009, 09:56 AM   #3
simplified
Member
 
Registered: May 2007
Location: London, UK
Distribution: Kubuntu 9.04 x64 / Ubuntu Server 9.04 x64
Posts: 50

Original Poster
Rep: Reputation: 15
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
 
Old 07-13-2009, 10:00 AM   #4
ECRocker
Member
 
Registered: May 2007
Distribution: RHEL 5, Ubuntu 9.10, Fedora 12
Posts: 85

Rep: Reputation: 17
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.
 
Old 07-13-2009, 10:04 AM   #5
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,528

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
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>)

Last edited by repo; 07-13-2009 at 10:07 AM.
 
Old 07-13-2009, 10:12 AM   #6
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,087

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
what is the command to add text into a text file? newbiebash Programming 2 09-08-2008 09:07 AM
How to parse text file to a set text column width and output to new text file? jsstevenson Programming 12 04-23-2008 03:36 PM
bash command redirecting output to file freeindy Programming 10 11-08-2007 06:48 AM
command output to text file? meniscus Linux - Newbie 4 10-05-2006 06:29 AM
Redirecting stdout from tar to a text file. heatlill Programming 2 01-22-2002 11:27 AM

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

All times are GMT -5. The time now is 04:51 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration