Apr
16

Tip: Remove Long List of Files

How to delete long list of files in Linux?

Let’s say you have a long list of files that you want to delete and simply running rm -fv * just won’t work and Linux will let you know by giving you this error:

Argument list too long.

When you get this error, it means that the number of files is too many for the kernel to process.

There is a simple workaround for this.

By using xargs, you can pipe xargs into the command to process each output. This can be done like so:

ls | xargs rm -fv

This command will list all files in the working directory and execute delete without confirmation.

If it still returns the same error, you can use find and pipe xargs.

find . -type f | xargs rm -fv

The command find will search the current directory for all files, excluding directories, and delete without confirmation.

xargs is a versatile Linux and you can use the man page anytime if you want to know more.

man xargs

Related Posts

Post comment

CommentLuv Enabled

Powered by 1and1.comGlobat Webhosting Earn with Your BlogAdvertise @ PinoyTux

Search PinoyTux

Subscribe to Email Feeds

Enter Email Address:

Blog Lounge

Popular Posts

Recent Posts

Drop your Card Here

Recent Comments

Site Stats