You're viewing a comment by Syed and its responses.

Syed Permalink
May 01, 2015, 23:43

I have file starting every line with a number ,
I want to put a leading zero if the length of numbers is less than 9. for example if number is 45781239(eight digits) then I want to prepend it with '0'.

Any help highly appreciated

Comment Responses

Anirudh Permalink
February 01, 2016, 15:29
sed -e '/^[0-9]\{1,8\}/s/^/0/'

You could also do this in your case, as every line starts with a number:

sed -e '/^[0-9]\{9\}/!s/^/0/'

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "rocket_95": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.