Reputation: 4393
I need to replace a string in a file with another string, but before the replacement I need to lowercase the new string before passing it to sed
.
echo 'NEWSTRING' | tr '[:upper:]' '[:lower:]' | sed 's/foo/(my tr output in lowercase)/g' file.txt
My question is, How we could pass the replacement string as a parameter ?
Upvotes: 2
Views: 1012
Reputation: 58483
This might work for you (GNU sed):
sed 's/foo/\L'"NEWSTRING"'/'g file
Upvotes: 3