How to divide a list of values by a number in command line?

view full story

http://unix.stackexchange.com – I am trying to translate a simple program to the command line using unix utilities. For example, if I have a frequency list (after piping through uniq and sort) 5 x 4 y 1 z I want to print out, instead of the frequencies, the fraction of the times they occur: 0.5 x 0.4 y 0.1 z (I have a python program that does this, but I wanted to know if this could be done through the command line itself.) So far, I have tried to compute the sum <...>| awk -F" " '{print $1}' | tr '\n' +; echo 0 | bc but this is just giving me the output 5+1+4+0 without computing it. EDIT: I got the sum . I (HowTos)