Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 09-01-2003, 04:31 PM   #1
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.


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

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.


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


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 > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:20 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration