Ivor O’Connor

February 22, 2009

Awk and Sed one liners explained

Filed under: awk/sed, bash, cli, php, Uncategorized — Tags: , , , — ioconnor @ 7:44 pm

There is an excellent article at OS News here http://www.osnews.com/story/21004/Awk_and_Sed_One-Liners_Explained

Much of the stuff presented there is very useful. However… Yes there is a big “however”. Howevery do you really want to use these platform specific arcane relics that do not have the error handling capabilities needed to handle unexpected scenarios? Short answer… NO.

Use PHP instead. It can do everything awk/sed can much more easily. More importantly you can plan for the unexpected since you get errors back instead of just blindly assuming the awk and sed commands worked as they did in your microcosm of a test world.

Sure PHP is not always installed on the platform. Say you are planning to put your code in a debian package and you are afraid to use PHP since it does not come preinstalled. Well simply put the latest release of PHP as a requirement for your package. Done. Before your package is loaded PHP gets loaded so you have all the wonderful PHP tools and perhaps libraries available.

Then there is the matter of running your code run on windows platforms. Same thing. Require PHP to be installed first. You can find it here for free on the M$ world. Sure there are some cooler languages like python and ruby but they simply are not as solid as PHP nor do they have the excellent pear libraries.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: