I'd add a carriage return at the end of the printout so that the BMI figure isn't mashed together with the following command problem. Thus, the last line of the script would read: echo $1 $2 | awk '{printf("%.1f kg/m²\n", 703.06958*$2/$1^2)}' On Tue, 8 May 2012 02:14:34 -0500 (CDT) Mike Miller <mbmiller+l at gmail.com> wrote: > See my one-liner below, with documentation. > > Body Mass Index, or BMI, is weight/height², but weight is in kilograms and > height is in meters, so the units are kg/m². We usually measure height in > feet and inches and weight in pounds, so I wrote this little script for > computing BMI from height in inches and weight in pounds. I call the > script "bmi". Supposedly, if your BMI exceeds 30, you are obese and if it > exceeds 25, you are overweight. A lot of us sit around too much, so we > are prone to gain weight and to get type-2 diabetes. Good diet and > exercise are critical for prevention. > > I just thought you might like the little piece of awk code. I'm too lazy > to write out the if/else statements to get it to tell you if you are > underweight, normal, overweight or obese, or to tell you how many pounds > you should lose. I might add that someday. (I'm about 9 lbs overweight.) > > Inevitably someone will point out that it doesn't distinguish fat mass > from muscle mass, which is true. If you are unusually muscular, or the > opposite, you'll want to take that into account. It turns out to > correlate very well with harder-to-obtain measures of body fat. > > Mike > > > ---------------begin script on next line---------------- > #!/bin/bash > > # Computes your Body Mass Index (BMI) from height > # in inches and weight in pounds > # > # Syntax: > # > # bmi num1 num2 > # > # where num1 is height in inches and > # num2 is weight in pounds > # > # http://www.nhlbisupport.com/bmi/ > # > # Underweight = <18.5 > # Normal weight = 18.5–24.9 > # Overweight = 25–29.9 > # Obese = > 30 > > > echo $1 $2 | awk '{printf("%.1f kg/m²", 703.06958*$2/$1^2)}' > --------------end script on previous line--------------- -- Jason Hsu <jhsu802701 at jasonhsu.com>