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 01-09-2014, 07:16 PM   #1
kobeson
LQ Newbie
 
Registered: Jan 2014
Posts: 8

Rep: Reputation: Disabled
How to copy files to multiple directories


Hello,

I need to copy some files to many subdirectories.

The destination path would be /ftp/<IDO>/outbound/reports

where IDO its the ID of a user and there are more de 300.

if there were a few directorios i would do as follows;

cp files /ftp/100/outbound/reports/

but it might take a while doing that for 300 times on a weekly basis.
Please any help?

Thanks in advance.
 
Old 01-10-2014, 12:52 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Hi,

you could probably use something like:
Code:
for d in /ftp/*/outbound/reports ; do cp files $d ; done
HTH,

Evo2.
 
1 members found this post helpful.
Old 01-10-2014, 01:37 AM   #3
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,124

Rep: Reputation: 190Reputation: 190
how about using the recursive options for cp?

Quote:
cp -r files /ftp/<IDO>/outbound/reports
 
Old 01-10-2014, 01:50 AM   #4
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Quote:
Originally Posted by JJJCR View Post
how about using the recursive options for cp?
The problem is multiple targets not multiple sources.

Evo2.
 
Old 01-10-2014, 03:50 AM   #5
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,124

Rep: Reputation: 190Reputation: 190
Wink

Quote:
Originally Posted by evo2 View Post
The problem is multiple targets not multiple sources.

Evo2.
Okay, I was thinking actually that the user would just need to mirror the source to the destination. That's why I suggested the recursive copying.
 
Old 01-13-2014, 01:19 PM   #6
kobeson
LQ Newbie
 
Registered: Jan 2014
Posts: 8

Original Poster
Rep: Reputation: Disabled
Thanks everyone for your help.

i did it as evo2 said and it worked

for d in /ftp/*/outbound/reports ; do cp Care_Center_Call_Response_es_2013-12-01_2013-12-31.csv $d ; done

Best regards.
 
  


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
Copy files from multiple directories into one directory MadRabbit Linux - Newbie 8 02-07-2014 08:56 PM
[SOLVED] copy multiple files to multiple directories Sanderson Linux - Newbie 15 01-22-2013 11:17 AM
Creating a script to move or copy files into multiple directories below the files matthes138 Linux - Newbie 5 08-25-2009 05:57 PM
find and copy files into multiple directories avargas22 Linux - Newbie 2 04-01-2004 12:11 PM


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