Recursive execusion of commands in Linux command prompt

When we want to execute any command recursively for a directory, we can use find command for that.

find . -name 'blah*' -exec rm -rf {} ;

But some times, it gives the error as Argument list too long. In that kind of situations, we better we go for this.

find . -name 'blah*' -print0 | xargs -0 rm -rf

In the above case, did the trick without complaining (because it sends the results of find to rm one by one, rather than in one large batch).

Leave a Reply

Your email address will not be published. Required fields are marked *