LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to write a script? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-write-a-script-737539/)

matthes138 07-03-2009 01:43 PM

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.

David the H. 07-03-2009 02:02 PM

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.

pixellany 07-03-2009 05:17 PM

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.....:)

matthes138 07-04-2009 11:04 AM

Thank you
 
thank you for your reply


All times are GMT -5. The time now is 08:45 AM.