Linux command line: recursively find all files with a given string

Posted by jason on Nov. 4, 2011, 6:25 a.m.
Tags: bash linux programming

Here's a little script I wrote that I install on any linux server that I do any programming on:

find . -type f -iregex '.*\.\(php\|html\|js\|css\|py\|lua\)$' -print0 | xargs -0 grep -n -i -H "$1"

Note that this searches all .php, .html, .js, .css, .py ...

Bash scripting: rename upper case file extensions to lower case

Posted by jason on Oct. 25, 2011, 10:18 p.m.
Tags: bash linux programming regex

I recently had one of my quick-and-dirty bash scripts broken because I wasn't expecting to receive a bunch of files named *.JPG as opposed to *.jpg. "Yay! I get to improve my bash script!" I thought to myself. Here's a script that will look at the files in ...

Fun with VIM, regex, and PHP

Posted by jason on Oct. 14, 2011, 6:52 p.m.
Tags: php programming regex vim


I've been having a lot of fun with regular expressions and vim lately, specifically while programming in PHP. Here are a couple of real-world examples where I saved myself a lot of time and increased my vim+regex skills in the process.

These examples are simple: I just ...

Merge PDF files using Python

Posted by jason on Sept. 28, 2011, 6:16 a.m.
Tags: programming python

Let me start this post with a disclaimer: I know there are tons of tools to do what I've done here, but I love python and look for any opportunity to write python scripts to keep my skills sharp. The script is 27 lines long, it does what I ...

Moodle 2: Get number of students in a course

Posted by jason on June 15, 2011, 7:45 p.m.
Tags: moodle php programming web

I searched around and couldn't find anything about getting the # of students in a course in Moodle 2. So I wrote a function to do it. I basically just copy-pasted the needed stuff from the /user/index.php file. Yes, this function is ridiculously long, considering the simple question ...