Remove multiple files

Posted on Sun 15 January 2023 in Linux • 1 min read

Sometimes, I need to delete multiple gigantic files (usually logs) at once and the following message is generated

/bin/rm Argument list too long 

So what to do?

Just enter the directory where the files are found and run some command alternatives

To delete all files containing "2023" in your name:

    $ for a in *2023*; do rm $a; done

To delete all files that have the log extension

    $ for a in *.log; do rm $a; done

Easy peasy! :)