Ack & Xargs For Global Replacement

Posted: November 17, 2009 in Uncategorized

For future reference:

ack "term_one" * -l | xargs -n1 --replace sed -i 's/term_one/term_two/' {}

RHEL 4/5, IIRC don’t require “-n1″ and “–replace”.

Advertisement
Comments
  1. Grep is great, but ack is even better! :)

    Thanks for the solution. That’s what I was looking for.

Leave a Reply

Please log in using one of these methods to post your comment:

Gravatar
WordPress.com Logo

Please log in to WordPress.com to post a comment to your blog.

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