I’ve been reading about sed
and found that it was evolved from grep
command.
According to https://en.wikipedia.org/wiki/Sed ,
First appearing in Version 7 Unix, sed is one of the early Unix commands built for command line processing of data files. It evolved as the natural successor to the popular grep command. The original motivation was an analogue of grep (g/re/p) for substitution, hence "g/re/s".
Sed search and replace
sed 's/old/new/' Example.txt
Thus, I was wondering if grep
can perform the search and replace function just like sed
.
If this is possible, please let me know how to accomplish the same via grep
, and not via sed
.
grep
stands for globally search a regular expression and print. So it is out of its scope to do replacements. I suggest you to use the right tool for the right job.sed
orawk
are better suited for this. – fedorqui Jun 26 '17 at 10:54It evolved as the natural successor to the popular grep command.
it means that grep was used to search and print a pattern, while sed can search and print or even replace a pattern. – George Vasiliou Jun 26 '17 at 12:48sed
was created after that. I would like to accept this as the best answer, however this is a "comment". – Charlotte Russell Jun 26 '17 at 14:03