LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 09-01-2003, 04:31 PM   #1
acid2000
Member
 
Registered: Nov 2001
Location: Exeter, UK
Distribution: Gentoo 1.4
Posts: 243

Rep: Reputation: 30
move files to a series of subdirectories


how do I move one file to a series of subdirectories all of different names.

If they were numbered etc i would of used a for loop I would just like to know if there is anyway to move one file to every subdirectory.

e.g.

move file ghi to all the directories in in the current directory.
 
Old 09-01-2003, 05:44 PM   #2
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 388

Rep: Reputation: 52
How about this:

find -type d -maxdepth 1 -print0 | xargs -0 -n1 cp ghi

Change the -maxdepth value to copy ghi to directories deeper than just the ones directly under the current directory. Leave the -maxdepth option off altogether to copy ghi into every directory under the current directory no matter how deep they get.

You'll get a message about trying to overwrite ghi with itself in the current directory, but that shouldn't be a problem.

Lyle

Last edited by lyle_s; 09-01-2003 at 06:44 PM.
 
1 members found this post helpful.
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot using FTP move command to move files adrianmak Linux - Networking 4 04-21-2009 12:01 PM
copy 3 files to a directory and all subdirectories? snip128 Linux - Newbie 9 08-12-2005 09:18 PM
Copying all files from subdirectories into one directory Hegemon Linux - General 3 01-17-2005 11:25 AM
Unzipping all .gz files in all subdirectories darin3200 Linux - General 10 04-24-2004 09:58 PM
delete files / keep subdirectories? lhorstman Linux - Newbie 2 01-10-2003 03:01 PM


All times are GMT -5. The time now is 07:38 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration