I am a beginner in linux.

I am trying to move specific 25k folders from directory containing 90k folders to another location. I have the folder names and tried the following command:

cp -r /path/{folder1,folder2,...} /path

It works for 200 folders, but for a bigger number it fails because argument list is too long.

Is there any other command or to read them from a text/csv file?

  • "I have the folder names..." How? Where? In a text file? Also, do you want to move or copy? Dec 17, 2022 at 13:13

2 Answers 2


if have text/csv you must read each line of file and run cp for copy folder,

recommend to use xargs or parallel or rush(source), this commands execute specific app for each line.

for example if my listdir is in LIST_DIR.txt similar to this:


i must this command for copy folders to destination

cat LIST_DIR.txt | rush 'cp -r /path/{} /path'

or with xargs

cat LIST_DIR.txt | xargs -I {} cp -r /path/{} /path
  • you can use -j N in rush, for run N jobs in parallel
    – Baba
    Dec 17, 2022 at 1:38

The typical solution approach for this type of problem is to use the xargs UNIX utility, which repeatedly runs a command with input arguments provided in a file and/or via stdin.

Here's a blog post with many examples of using xargs

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .