I want to print numbers in a bash script using the following C format : %05d.
So I have two variables
$num1
$num2
And when I set for example num1=12 I would like to have echo $num2 equals to 00012.
How to do that ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Note that this sets num2 only once. If you want num2 to always reflect the current value of num1, you need to define it as a function:
…and then call it as such: