LinuxQuestions.org
Review your favorite Linux distribution.
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, 06: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-09-2014, 11:52 PM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
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, 12:37 AM   #3
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,148

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

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

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
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, 02:50 AM   #5
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,148

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
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, 12: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 07:56 PM
[SOLVED] copy multiple files to multiple directories Sanderson Linux - Newbie 15 01-22-2013 10:17 AM
Creating a script to move or copy files into multiple directories below the files matthes138 Linux - Newbie 5 08-25-2009 04:57 PM
find and copy files into multiple directories avargas22 Linux - Newbie 2 04-01-2004 11:11 AM

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

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