search & replace in matching files
reoccurring task:
- replace every occurence of
FOO
withBAR
-
only in
*.h
and*.cpp
filesag -G "\.(h|cpp)" FOO -l | xargs sed -i 's/FOO/BAR/g'
In this command I use ag
-- the silversearcher
-
ag -G
allows you to narrow the search to certain file types -
-l
will cause ag to only list files that contain the pattern
Written by Oliver Mueller
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Sed
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#