LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   move files to a series of subdirectories (https://www.linuxquestions.org/questions/linux-general-1/move-files-to-a-series-of-subdirectories-88121/)

acid2000 09-01-2003 04:31 PM

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.

lyle_s 09-01-2003 05:44 PM

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


All times are GMT -5. The time now is 12:15 AM.