tips

You are currently browsing articles tagged tips.

This one’s really basic, but just because you’re an ace php developer doesn’t necessarily mean you’ve had a chance to discover all the ins and outs of bash and the linux command line. One of the guys in the office recently asked me how to make a change to multiple files in his code base with a single line command. Find and sed are your friends here. Since I’m a huge fun of doing as many things as possible with one liners, here’s the gist of what we did.

find . -name '*.php' -exec sed -i -e"s#search#replace#g" {} \;

Find the files you want, run sed on each one of them, edit inline with the included expression, done.

Big thing to note is sed using ‘#’ for a seperator and not ‘/’ . I believe the man page still talks about using a forward slash, but ‘#’ works.

The results from your find command are run through the {} so don’t forget that, and a find -exec must be terminated with a \;

Enjoy.

Tags: , , ,

As part of my on going effort to do anything at all with this blog, I’ve decided to start posting any little linux tidbits that spin out of the day to day here at b5media. This new category is where I’ll slap up anything that folks new to linux, or looking for the odd time saver here or there might appreciate.

Tags: , ,

Get Adobe Flash playerPlugin by wpburn.com wordpress themes