I have a list of numbers, for example

1394

49020

344

34

4904290

2350

5

I am trying to prepend '0' to the four-digit numbers using sed, so the example above should give '01394' and '02350' and leave everything else as is.

The command I am using is `sed 's/[0-9]\{4\}/0&/'`

but this includes numbers four digits and greater. I tried including end of line to indicate that I only want four digit numbers like so: `sed 's/[0-9]\{4\}$/0&/'`

but this added a '0' to the second place of the five-digit numbers, so in the example above, '49020' would become '409020'.

Would appreciate any help on this!