Interesting / Useful Commands
There are two Mac specific commands that I'll share as being particularly useful, while also not being readily apparent to a Linux convert:
- dscacheutil -flushdns -- Flush your DNS cache
- say -f filename.txt -o filename.mp4 -- Text to Speech into an MP4 audio file
Get your MacBook's battery status from the command line
While I'm sharing, here's how to get your battery's charge level from the command line on OSX Lion. (I can't vouch for Mountain Lion, but it might work there as well.)file #1 (battery) -- shell script
-----------------------------------------------------
#!/bin/bash
ioreg -l -w0 | grep LegacyBatteryInfo | awk -f ~/bin/battery.awk
file #2 (battery.awk)
-----------------------------------------------------
BEGIN { RS=","
FS="=" }
/Capacity/ {capacity = $2}
/Current/ {current = $2}
END { print "Battery charge remaining: " 100*(current/capacity) "%" }
On my machine, the output looks like this:
jtss-MacBook-Air:bin jts$ ./battery
Battery charge remaining: 67.7165%
jtss-MacBook-Air:bin jts$