Reveclair
Reveclair

Reputation: 2421

How writing a shell script to add enough zeros to have six digits for each number?

I have a list of numbers (each number having less than 6 digits) in a .tsv file like that :
4559
123
etc

and I need to have a list of numbers of 6 digit like that :
004559
000123
etc

Thanks a lot

Upvotes: 3

Views: 335

Answers (1)

Anya Shenanigans
Anya Shenanigans

Reputation: 94859

There's printf in bash that does exactly this -

printf "%0.6d" $value

Upvotes: 6

Related Questions