Regular Expressions For Regular Work

Time and again I saved a lot of time for the company I work for, the group I am part of and to myself by writing simple scripts. These scripts were written in sh/tcsh/bash, sed, awk and perl. One thing common in almost all these scripts is the usage of regular expressions either to parse the files or to get the list of files to process.

One of my favorite pattern is

find . -name 'some-regex-pattern' -print | xarg -iFILE some-shell-command

What this does is, recursively gets the list of all files from a directory that match a particular regular expression pattern and then make them available as a FILE variable and execute some shell command that contains FILE word which gets substituted with the actual file.

For any aspiring developer learning and Mastering Regular Expressions is very important. Infact, even as a development manager who needs to often analyze a set of existing files to decide on a project like introducing changes across the entire set of files or determining design change impact etc can be easily done using the regular expressions.

The book Mastering Regular Expressions is supposed to be one of the best books for learning regular expressions.

Leave a comment

Filed under Programming, Scripting, Tech Books

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s