Reputation: 8386
Already spent a lot of time with the sed and gsed, by just trying to match a stupid string, but it still doesn't work!
neither:
echo "123adv123" | sed -En 's/\([a-z]+\)/#/g'
nor:
echo "123adv123" | sed -En 's/([a-z]*)/#/g'
nor:
echo "123adv123" | sed -En 's/([a-z]+)/#/g'
nor:
echo "123adv123" | gsed -rn 's/\([a-z]+\)/#/g'
nor:
echo "123adv123" | gsed -rn 's/([a-z]+)/#/g'
I'm trying it on the OSX. I know the question looks really strange, but I stucked and just want to get the glue what is wrong here?
The output should be 123#123
Upvotes: 0
Views: 89
Reputation: 784968
You need to remove -n
otherwise it will suppress output.
This works on OSX:
echo "123adv123" | sed 's/\([a-z][a-z]*\)/#/g'
So is this:
echo "123adv123" | gsed -r 's/([a-z]+)/#/g'
Or this:
echo "123adv123" | sed -E 's/([a-z]+)/#/g'
Or to print only substituted lines use:
sed -nE 's/([a-z]+)/#/pg' file
Upvotes: 2