# Operating Systems > Unix/Linux Math Calculations - Unix Shell

## basehit524

Can someone tell me how to do the following inside a unix script?

I have a file and can do a wc -l on it....say the count is 123 lines.

#wcl  /tmp/file
>123

I would then like to divide this number by 2 to get a decimal number.

# wcl /tmp/file| `expr /tmp/file /2`

Can't find the right expr combo.

Any idea how to accomplish this?

Thx.
Kurt

----------


## Sanpri

Hi,

you can first store the o/p of wc -l value in a variable.

say a = wc -l /tmp/file.

then b=`expr $a/2`

Thanks.

----------


## vishalcjha

ur approch is right but u need to change some thing 
as wc -l does not only returns file rows it also return file name so that name can not be divided 
so use cut to remove that file name 
also make sure in expr there should be space around arithmetic operator

----------

