remove leading zeros in shell script

I need help in shell script to remove leading zeros from a number

for example: x= "01"
and I need the result x= "1" or in another variable y="1"
welcome 123Asked:
Who is Participating?
 
MacroShadowConnect With a Mentor Commented:
y="$(echo $valueWithZeroes | sed 's/0*//')"
0
 
woolmilkporcCommented:
x=$((x))

x=${x#0}
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
x=$(bc<<<$x)
0
 
MikeOM_DBACommented:
Or just convert to integer:
(( x += 0 ))

Open in new window

:p
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.