The above article and the script it contains was designed for Mac OS X 10.4.3. This article, get sensor information, shows how to use ioreg to extract the fan speed information with: ioreg -c IOHWSensor | grep -B3 -A11 ''type' = 'fanspeed''
See Can I get the CPU temperature and fan speed from the command line in OS X? Pre-Mac OS X 10.5
Other tools and applications exist, including Temperature Monitor. This is a computationally expensive process, even when run for one second. Spindump requires administrator privileges and when run manually, spindump samples user and kernel stacks for every process in the system. This article, OS X: Current CPU temperature on command line, talks about the project and how to extract the fan speed: smc -k TC0D -r | sed 's/.*bytes \(.*\))/\1/' |sed 's/\(*\)/0x\1/g' | perl -ne 'chomp ($low,$high) = split(/ /) print (((hex($low)*256)+hex($high))/4/64) print 'C\n' ' The open source project Fan Control includes a command line tool that provides fan speed information. It appears no tool, installed by default on OS X, exposes this information through the terminal. Since Mac OS X 10.5, you need to use a third party piece of software to access the fan speed information. See the smc manual page for more options. You can use smc to get fan speed information via Terminal.app: smc -f
You mention in your comments having smcFanControl installed this open source project includes the command line tool smc.