FG

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

Fresh3 days ago
Mar 15, 202653795 views
Confidence Score0%
0%

Problem

I have a directory containing around 280,000 files. I want to move them to another directory. If I use or then I get an error 'argument list too long'. If I write a script like then, because of the command, its performance degrades. How can I do this?

Error Output

for file in ls *; do
   cp {source} to {destination} 
done

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

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

Low Risk

Use rsync: e.g. (note the trailing /s) Note: if it's a lengthy operation and you want to see some indication of progress during copying you can either add the (verbose) option, which then lists every file being copied, or consider using the option, …

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment