How to convert all numbers in Bash/shell?
VAR=00005
VAR=00010
VAR=00601
VAR=00550
to
echo $VAR #5
echo $VAR #10
echo $VAR #601
echo $VAR #550
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.
or like this:
for your updated question (with VAR)
first of all, you should have different variable names, not all same as VAR.
see the example below:
EDIT
for the comment.(08, 09 didn’t work):
08, 09 worked here, might be something with my shell to do. I have zsh. I tested followings under bash, they worked. hope helps:
under zsh:
under bash, below worked