Delete x files from folder in a for i loop

Recently I tried to remove a big bunch of files from one of my raspberry pies where ffmpeg had swamped my SD-card with too many capture images. So I had to delete x files from folder.

I just tried:

But that gave me an “unable to execute /bin/rm: Argument list too long” error message.

So I needed a bash script that helps me to delete x files from folder. That’s why I wrote this tiny snipped:

If deleted 50 files of type jpg from the current folder.

For more information about using loops, have a look at my convert cr2 to jpg article.

Leave a Reply

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