insert multiple characters in string

Hello, newb here :-[

How do I add square brackets before and after the first character in a string using sed?

e.g. 
0123456
[0]123456

My attempts have been fruitless.

sed ‘s/.{0}/[/;s/.{1}/]/’

Thanks.

There’s probably a more elegant solution (I’m no sed expert myself), but try inserting one character at a time, then piping the output back to sed for a second operation:-

sed 's/^\(.\{0\}\)/\1[/'

This will insert a [ at the beginning

sed 's/^\(.\{2\}\)/\1]/'

This will insert a ] after (what is now) the second character

So piped together …

echo "0123456" | sed 's/^\(.\{0\}\)/\1[/' | sed 's/^\(.\{2\}\)/\1]/'
output =
[0]123456