I need to move 1000s of files from one folder to another.
Actually there are 100K+ files.
Source dir : source1
Target dir : target1
Now if try cp or mv commands I am getting an error message : Argument List too long.
I tried to do it by the time the files are created in the source folder.
-rw-r--r-- 1 prod usr1 104 Dec 3 08:01 200912_011.txt
For example the above file we can see that files can be seggregated based on the timings - 08:01 > 1000 file
08:02 > 1000 file.
I can select the time from the ls -lrt command using awk '{print $8}'.
But not able to move files writing a command line. This is how I tried, any solution is welcome.
Unless the files are being transferred to a different filesystem, I would recommend mv so that you are not touching the data inside the files, but rather only manipulating directory entries, a far less intensive activity. If different filesystems are involved, mv will arrange a copy, if I recall correctly.
The command
xargs - build and execute command lines from standard input
was invented to deal with the issue of long argument lists. See man xargs, search the forums, and experiment to see how it will address your problem.