Sample Header Ad - 728x90

Moving random files using shuf and mv - Argument list too long

3 votes
1 answer
2670 views
I have a directory containing nearly 250K files, which are lots of files, and I want to move x random files to another directory. I searched and I got the solution of using the shuf and mv commands from here and here , so basically I am using this command $ shuf -n 5533 -e trainB/* | xargs -i mv {} testB/ But I'm receiving this error: bash: /usr/bin/shuf: Argument list too long I believe because of the large number of files, so accordingly, the argument list is too long, is there another way to do this? I'm running on SLES12 SP2.
Asked by Mostafa Hussein (273 rep)
Sep 3, 2018, 04:07 PM
Last activity: Sep 3, 2018, 04:37 PM