Issue
If I, for example, want to open all files with the int
statement in them, I use grep and pipe the search results to vim
using xargs
grep -rl 'int' . | xargs vim
Typically, if I want to replace int
with float
, I do so like through sed
like so
sed 's/\<int\>/float/g' foo.c
But how would I combine the two if I want to find all files that have the word int
in them and then do word replacement on the file inline (eg. sed -i 's/\<int\>/float/g'
)
Solution
But how would I combine the two
You would do just:
grep -rl 'int' . | xargs sed -i 's/\<int\>/float/g'
Answered By - KamilCuk Answer Checked By - Willingham (WPSolving Volunteer)