LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-12-2004, 07:06 AM   #1
sneak
LQ Newbie
 
Registered: Feb 2004
Posts: 21

Rep: Reputation: 15
how to use the output of a file for input of a command


hello,

I have copied the contens of a bin directory to my /usr/bin directory.
and now I want to remove all the files that i copied in there.
but i don't want to type all of the files after the rm command. so I figured: why dont I just take the input of the list command from the first bin directory and use it on the remove command in the other.

so why wont this work?

ls > remfiles
cp remfiles /usr/bin
cd /usr/bin
rm < remfiles

(as root off course)
 
Old 05-12-2004, 08:09 AM   #2
javpra
Member
 
Registered: Nov 2003
Distribution: FreeBSD/Gentoo/Debian
Posts: 52

Rep: Reputation: 19
ls > remfiles only copies the output of the "ls" command to the file "remfiles" not the actual files/programs.. The "<" is used for redirection of output/input. I am not sure how many files you are trying to move and delete. If it is a relatively small amount you can type a partial file name and press the TAB key and the shell will automatically complete the rest of the file name. If all the files are of the same type , for example .wav files, you can type
rm *.wav
and all files of that type will be removed. Likewise if you want to copy all files of a type you can use the command
cp *.wav /usr/bin
and all .wav files will be copied to /usr/bin. I hope this is of some help.

Last edited by javpra; 05-12-2004 at 08:10 AM.
 
Old 05-12-2004, 09:21 AM   #3
Ma3oiS
LQ Newbie
 
Registered: May 2004
Posts: 12

Rep: Reputation: 0
Code:
ls > remfiles            # OK
cp remfiles /usr/bin     # OK
cd /usr/bin              # OK
rm < remfiles            # bad - should be rm -f `cat remfiles`
# and you should add:
rm remfiles
With rm, files to operate on must be specified as parameters because rm doesn't read standard input.
'rm -f' will not ask you if you really want to delete files
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Output the result of a command to a file darkarcon2015 Linux - Newbie 1 09-24-2005 06:29 PM
Command line to get output on a file satimis Programming 4 06-24-2005 06:04 AM
Can't rm file with Input/Output error drlaz Linux - General 0 02-23-2005 06:06 PM
Help: Command Output to File. rvijay Linux - Newbie 3 09-30-2003 09:02 AM
logging all keyboard input/output to a file div Linux - General 0 02-20-2001 05:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:41 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