Gnuru.org
Productive Linux


Subscribe

 Subscribe via Feedburner in a reader

Enter your email address:

Delivered by FeedBurner


Login
Login:
Password:



Don't have an account?
Sign up to Gnuru.org
Forgot your password?

Fun with sed
20 July 2011 @ 20:34 BST
by Paul

Everyone should learn sed, especially me:

sed '/use Moose::Policy/ d; /use Moose;/ a \
use MooseX::FollowPBP; \
' lib/interestingfile.pm

and even better:

find lib -name '*pm' -exec sed -i '/use Moose::Policy/ d; /use Moose;/ a \
use MooseX::FollowPBP; \
' '{}' \;

In relation to sed the -i switch means amend the file in place. The 'd' command is delete the line with the preceeding match and the 'a' command means append the following line after the preceeding match.




Comments disabled