grep -r 'foo' | xargs sed -i 's/foo/bar/g'
I am using this command to replace all items of foo to bar. However, I want to only replace foo with bar in the first 5 files. Somehow I would need to cut the output of grep to just the first 5 items, or get xargs to only get the first 5 items from the output.
Thanks!