Thursday, July 1, 2021

To remove or delete files in Linux when there are more

When there are too many files to delete in a Linux folder, its hard to delete as "rm" won't work directly.

Below is the error message, we get.

$ rm -rf "*.csv"
-bash: /usr/bin/rm: Argument list too long

Resolution:
$ find . -name '*.csv' | xargs rm -v4

This will remove all files which have ".csv" as extension and give verbose output of what it is doing while removing.

***

No comments:

Post a Comment