I have one awk and one sed example. Both seems to be using the same regular expression, but the output differs. So the pattern expansion must be getting different. But i can not get the difference. Can anyone explain?
$ echo "THE BEAR ATE THE FISH" |sed -e 's/[^ ]*(H|F)[^ ]*/<red>&/g'
THE BEAR ATE THE FISH
$ echo "THE BEAR ATE THE FISH" | awk 'gsub(/[^ ]*(H|F)[^ ]*/,"<red>&")'
<red>THE BEAR ATE <red>THE <red>FISH
$ sed --version
GNU sed version 4.1.5
$ awk --version
GNU Awk 3.1.5