M
M
microphone2015-03-24 16:56:09
bash
microphone, 2015-03-24 16:56:09

How to align digits in BASH/SH?

How to align number width in BASH/SH
For example: there is a stream that needs to be generated like this
"prefix"+"4digit_number"+"postfix"
D0001ba
D2ba
...
D10ba
...
<--
how to align the number of characters in a number?
D0001ba
D0002ba
...
D0010ba
D0011ba
<-- want this

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Armenian Radio, 2015-03-24
@microphone

printf "PREFIX%04dPOSTFIX\n" 50
PREFIX0050POSTFIX

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question