I found (on Google) this perfectly working line to replace every occurences in all files in my directory and subdirectories:
grep -lr previoustext | xargs sed -i 's/previoustext/newtext/g'
It works great.
But now I'm trying to use it in a function in my bash_aliases file as following:
freplace() {
grep -lr previoustext | xargs sed -i 's/previoustext/newtext/g';
}
However, when I call
freplace previoustext newtext
in my terminal, nothing happens ... . The text is not replaced.
Any idea why it doesn't work ?