LinuxQuestions.org
Help answer threads with 0 replies.
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 04-26-2004, 01:41 PM   #1
tgolly
LQ Newbie
 
Registered: Apr 2004
Posts: 2

Rep: Reputation: 0
Copying a single file to multiple directories


I want to copy a single file to a directory and all the subdirectories contained within the main directory. I want to be able to copy a file into about 10,000 folders, I need a quick way to do this, thanks.
 
Old 04-26-2004, 01:57 PM   #2
7ux_spirit
LQ Newbie
 
Registered: Apr 2004
Distribution: Redhat 8.0
Posts: 21

Rep: Reputation: 15
i dont think there is any standard command for copying to multiple locations.
u may try making a shell script
 
Old 04-26-2004, 03:12 PM   #3
tgolly
LQ Newbie
 
Registered: Apr 2004
Posts: 2

Original Poster
Rep: Reputation: 0
I'm not familiar with creating shell scripts, could anyone help me create one for this job, thanks.
 
Old 04-26-2004, 03:47 PM   #4
7ux_spirit
LQ Newbie
 
Registered: Apr 2004
Distribution: Redhat 8.0
Posts: 21

Rep: Reputation: 15
This script should work.
I dont know whether i could make this script more simpler, expecially that text filtering part with awk, there could be simpler tools for that!

#!/bin/bash
#rec_copy.sh
#Usage:
# rec_copy.sh input_file target_dir
# copies 'input_file' recursively to all directories starting at 'target_dir'

if [ -z $2 ]; then
echo "usage: $0 input_file target_dir"
exit
fi

#for i in $(ls -R $2| grep :$ | awk -F":" '//{print $1}' )
for i in $(ls -R $2 | awk -F":" '/:$/{print $1}' )
do
cp $1 $i
done

Last edited by 7ux_spirit; 04-26-2004 at 04:51 PM.
 
  


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
BASH Shell script : copying a file to multiple folder zamri Programming 14 04-29-2008 10:27 AM
Searching multiple directories and sub directories for a file jeep99899 Linux - Newbie 2 10-13-2005 12:23 PM
single ext3 journal device multiple journaled file systems? reelwylde Linux - General 4 09-08-2005 03:00 PM
Copy one file to multiple directories cmfarley19 Linux - General 9 11-10-2004 12:57 PM
merge multiple lines of a single file into one line groverrajiv Linux - Newbie 4 05-26-2004 02:38 AM

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

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