argument list too long
"Argument list too long" from rm, cp or mv: too many files for one command line. Hand them over in batches.
danger Steps marked in red delete, overwrite or stop something. Read each one before you run it.
Steps
-
find . -maxdepth 1 -name '*.log' -deletedanger delete them without listing them on the command line
-
find . -maxdepth 1 -name '*.jpg' -exec mv -t /dest/ {} +move them, many at a time (GNU mv)
-
printf '%s\0' *.log | xargs -0 rmxargs makes batches that fit
-
getconf ARG_MAXhow long a command line can be here
Commands used
findxargsgetconf
Each has a page in lore: lore find opens it.
Related recipes
- add to the end of a fileAdd lines to a file without replacing it, also to a file only root can write.
- get a file's name, folder and extensionTake a path apart in a script: the folder, the name, the name without its extension, the extension.
- rename many filesChange the ending of many files, replace spaces in names, or number them.
- add a folder to the pathLet the shell find programs in a folder, for good, and reload the settings without logging out.