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-03-2009, 02:43 PM   #1
matthes138
LQ Newbie
 
Registered: May 2009
Posts: 6

Rep: Reputation: 0
How to write a script?


How do you write a script that will read in a list of directories and then copy a set of files in to each of the directories that it read in from the list? System in Cent OS 5 latest version.


Thank you for your help in advance.
 
Old 07-03-2009, 03:02 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian + kde 4 / 5
Posts: 6,837

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
Try working your way through a simple scripting tutorial. I recommend Linuxcommand.org.

What you're asking is very simple; just a "for" loop to iterate through your list and run the copy command on the directory name.
 
Old 07-03-2009, 06:17 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
The absolute best way to learn scripting is to first experiment with the basic commands---one at a time.

In this case, I think you are saying you have a file with a list of directory names---let's call it "namefile".

First, try:
Code:
read name < namefile
echo $name
Now do this:
Code:
while read name; do echo $name; done < namefile
Your script is now practically complete.....
 
Old 07-04-2009, 12:04 PM   #4
matthes138
LQ Newbie
 
Registered: May 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Thank you

thank you for your reply
 
  


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
How to write a script blck_kenzo Linux - Newbie 2 05-25-2009 01:29 AM
Better way to write this script faizlo Programming 6 01-08-2009 03:25 AM
How to write this script? cghcgh Programming 9 05-28-2008 05:36 AM
How to write a Script Blake Linux - Software 6 07-18-2004 12:41 PM

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

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