# command for converting string to integer

**URL:** <https://community.unix.com/t/command-for-converting-string-to-integer/155164>\
**Category:** Shell Programming and Scripting\
**Created:** [August 4, 2005, 7:01am UTC](https://community.unix.com/t/command-for-converting-string-to-integer/155164 "2005-08-04T07:01:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![esham](https://community.unix.com/user_avatar/community.unix.com/esham/32/134_2.png) [@esham](https://community.unix.com/u/esham)\
**Post date:** [August 4, 2005, 7:01am UTC](https://community.unix.com/t/command-for-converting-string-to-integer/155164/1 "2005-08-04T07:01:51Z")

</div>

Hi ...

I am trying to calculate the time needed for a command to execute..

but the resulting value is getting as string..

> [@](#):
>
> (time -p cp /home/esham/speedtemp3 /home/ ) 2\>file ; grep sys file | cut -d" " -f 2

so i am not able to use "expr " command..

please help me to convert the value to integer so that i can proceed with my script..

Regards

esham

---

<div class="post-metadata">

**Author:** ![vino](https://community.unix.com/user_avatar/community.unix.com/vino/32/156_2.png) [@vino](https://community.unix.com/u/vino)\
**Post date:** [August 4, 2005, 7:20am UTC](https://community.unix.com/t/command-for-converting-string-to-integer/155164/2 "2005-08-04T07:20:04Z")

</div>

Use bc

Say TIME=0.02

```nohighlight
echo $TIME+1 | bc -l

```

will give

[~]$ echo $TIME+1 | bc -l  
1.01

vino
