Simple example of how to automate a folder cleaner using shell scripting:

#!/bin/bash

rm *.log
rm *.tmp
rm *.bbl
rm *.lof
rm *.dvi

At the top we have a line that lets the program know that we want it to run on bash. There are more shells than bash, for example dash or sh, etc. As you can see # is what we use to mark a comment. Then we simply outline all the commands that the program would have to do. After this we can save and exit back to the terminal.

To make the program executable we need to change its chmod in this case we chage it to 755 whiche means that the owner can read, write, execute and the users and group can read and execute.