Well, I would recommend you to actually learn a programming language before you're going to program something, there plenty of people here that can point you in the right direction on how to learn a programming language.
However, if you're only interested in the answer to your question, I would recommend to look up how to make Unix (bash?) scripts, and looking at some basic things that you can do in the Terminal application (for example, Unix commands like 'cd' and 'ls'). After you master those things, it's really quite simple, just find find out how to search in Unix, and you're basically done. If you've any questions, feel free to ask here.
Good luck Googling!