Skip to main content

The maximum length of the command line is set by the system and is sometimes 128KiB.

If you need to remove many, many files, you need to call rm more than once, using xargs:

find /var/log -type f -print0 | xargs -0 rm --

(Careful, this will find and delete all files in the subdirectories of /var/log etc. - if you do not want that use find /var/log/ -type f -maxdepth 1). The find lists the files, 0-delimited (not newline), and xargs -0 will accept exactly this input (to handle filenames with spaces etc.), then call rm -- for these files.

Use rm -f -- (with caution) if you are asked whether files should be removed, and you are sure you want to remove them.

The maximum length of the command line is set by the system and is sometimes 128KiB.

If you need to remove many, many files, you need to call rm more than once, using xargs:

find /var/log -type f -print0 | xargs -0 rm --

(Careful, this will find and delete all files in the subdirectories of /var/log etc. - if you do not want that use find /var/log/ -type f -maxdepth 1). The find lists the files, 0-delimited (not newline), and xargs -0 will accept exactly this input (to handle filenames with spaces etc.), then call rm -- for these files.

Use rm -f -- if you are asked whether files should be removed.

The maximum length of the command line is set by the system and is sometimes 128KiB.

If you need to remove many, many files, you need to call rm more than once, using xargs:

find /var/log -type f -print0 | xargs -0 rm --

(Careful, this will find and delete all files in the subdirectories of /var/log etc. - if you do not want that use find /var/log/ -type f -maxdepth 1). The find lists the files, 0-delimited (not newline), and xargs -0 will accept exactly this input (to handle filenames with spaces etc.), then call rm -- for these files.

Use rm -f -- (with caution) if you are asked whether files should be removed, and you are sure you want to remove them.

Made a bit more clear
Source Link
Ned64
  • 9.3k
  • 9
  • 58
  • 94

The maximum length of the command line is set by the system and is sometimes 128KiB.

If Iyou need to remove many, many files, I wouldyou need to call rm more than once, using xargs:

find /var/log -type f -print0 | xargs -0 rm --

(Careful, this will really find and delete all files in the subdirectories of /var/log etc. - if you do not want that use find /var/log/ -type f -maxdepth 1). The find lists the files, 0-delimited (not newline), and xargs -0 will accept exactly this input (to handle filenames with spaces etc.), then call rm -- for these files.

Use rm -f -- if you are asked whether files should be removed.

The maximum length of the command line is set by the system and is sometimes 128KiB.

If I need to remove many, many files, I would call rm more than once, using xargs:

find /var/log -type f -print0 | xargs -0 rm --

(Careful, this will really find all files in the subdirectories of /var/log etc. - if you do not want that use find /var/log/ -type f -maxdepth 1) The find lists the files, 0-delimited (not newline), and xargs -0 will accept exactly this input (to handle filenames with spaces etc.), then call rm -- for these files.

Use rm -f -- if you are asked whether files should be removed.

The maximum length of the command line is set by the system and is sometimes 128KiB.

If you need to remove many, many files, you need to call rm more than once, using xargs:

find /var/log -type f -print0 | xargs -0 rm --

(Careful, this will find and delete all files in the subdirectories of /var/log etc. - if you do not want that use find /var/log/ -type f -maxdepth 1). The find lists the files, 0-delimited (not newline), and xargs -0 will accept exactly this input (to handle filenames with spaces etc.), then call rm -- for these files.

Use rm -f -- if you are asked whether files should be removed.

Source Link
Ned64
  • 9.3k
  • 9
  • 58
  • 94

The maximum length of the command line is set by the system and is sometimes 128KiB.

If I need to remove many, many files, I would call rm more than once, using xargs:

find /var/log -type f -print0 | xargs -0 rm --

(Careful, this will really find all files in the subdirectories of /var/log etc. - if you do not want that use find /var/log/ -type f -maxdepth 1) The find lists the files, 0-delimited (not newline), and xargs -0 will accept exactly this input (to handle filenames with spaces etc.), then call rm -- for these files.

Use rm -f -- if you are asked whether files should be removed.