Delete rest of line with sed works on Linux but not on Solaris

Hi all,

Our application installation uses "sed" command to delete rest of line. It work perfect on Linux but fail on Solaris.
The OS versions are Solaris 9 and Linux Red Hat AS 3.

yourfile.txt

hello and world
cat and dog
hello world

in linux:

cat yourfile.txt | sed �s/\([^ ]\+\) *and.*/\1/g' > out.txt

then my out.txt look like now

hello
cat
hello world

=========================
in Solaris

cat yourfile.txt | sed �s/\([^ ]\+\) *and.*/\1/g' > out2.txt

out2.txt

hello and world
cat and dog
hello world

Any one know why it does not work on Soloris?

Thank very much

Kevin

echo 'hello and world' | sed 's/\([^ ][^ ]*\) *and.*/\1/g'

If this is NOT what you want, explain what you're trying to achieve.

sed 's/ and.*//' yourfile

Thanks very much , I think it work.

kevin