Home » Questions » Computers [ Ask a new question ]

Copying large number of files from one directory to another in Linux

Copying large number of files from one directory to another in Linux

I have a directory containing around 280,000 files. I want to move them to another directory.

Asked by: Guest | Views: 338
Total answers/comments: 4
Guest [Entry]

"How about when moving (instead of copying):

$ find {origin}/ -maxdepth 1 -name ""*"" -o -name "".*"" -exec mv '{}' {destination}/ ';'

I think that will move keeping the structure (subdirs) and hidden files or dirs, plus no extra space consumed as with rsync + rm. And if {origin} and {destination} are in the same partition it will be faster."
Guest [Entry]

Assuming you want to move the files within the same filesystem, you could just rename the directory containing your lacs and be done with it.
Guest [Entry]

"I like rsync for this, or:

find dir1 -type f -exec cp {} dir2 \;"
Guest [Entry]

"Using tar:

(cd {origin}; tar cf - .)|(cd {destination}; tar xvf -)

Works to get things started when the origin is initially too big for rsync but the deltas are not."