Appending line with sed works on Linux but not on Solaris

Hi folks,

Our application installation uses "sed" command to append string after specific line or after line number.
Both cases work perfect on Linux but fail on Solaris.
The OS versions are Solaris 9 and Linux Red Hat AS 3.

i.g:
Linux:
-----
file foo.txt

aaa
bbb
ccc
ddd
root# uname -s                           
Linux
root# sed '2a\Add this line after line 2\' foo.txt
aaa
bbb
Add this line after line 2
ccc
ddd
root# sed '/bbb/ a\Add this line after bbb' foo.txt
aaa
bbb
Add this line after bbb
ccc
ddd

Sun Solaris
-----------

root# uname -s
SunOS
root# sed '/bbb/ a\Add this line after bbb' foo.txt
sed: command garbled: /bbb/ a\Add this line after bbb
root# sed '2a\Add this line after line 2\' foo.txt
aaa
bbb
ccc
ddd

As you can see,sed works fine on Linux but not on Solaris.
Is there a different in sed syntax between platforms?

Thanks in advance,
Nir

The problem is the same for AIX
You must have a new line after the \

sed '2a\
Add this line after line 2' foo.txt

or

sed '2a\^JAdd this line after line 2' foo.txt

^J is inserted with ^V+^J

Hi aigles,

Thanks for your reply.
Both suggestions failed:

root# sed '2a\Add this line after line 2' foo.txt
sed: command garbled: 2a\Add this line after line 2
root# sed '2a\^JAdd this line after line 2' foo.txt
sed: command garbled: 2a\^JAdd this line after line 2

Any other suggestions?

Thanks in advance,
Nir

For the first solution don't forget the newline after 2a\.
\ MUST be the last character of the line.
The second part of the command must be in a second line.

root# sed '2a\
Add this line after line 2' foo.txt

Hi aigles,

Thanks a lot!!
It's working now perfect!!

Beset regards,
Nir