inserting variable in bash printf statement
In the following printf statement will print 1with padding 45 zeros.
Code:
printf '1%045d\n' Can anyone help me to do it ? |
Not sure I understand
printf is doing what you asked, Code:
for i in 0 {10..12};do |
I want to replace the 45 in with a variable. Means I want like this
Quote:
|
to what i have understood it you can try something like this, though i would defer to @Firerat to comment on this further, he may have a better option.
Code:
printf 1%0${var}d |
Quote:
unless,, Something like this? Code:
for VAR in 0 {10..12};do |
Place it also around double quotes to make it a little safer:
Code:
printf "%0${n}d\\n" 1 |
Quote:
|
Code:
printf '1%0*d\n' "$WIDTH" "$VALUE" |
Quote:
|
All times are GMT -5. The time now is 12:23 PM. |