nix, shell, perl, php, mysql and mac os x tips and tricks

Monday, June 15, 2009

Kill os x apps from the command line

ps axww | grep -v grep | grep -i itunes | awk '{print $1}' | xargs kill -9

Delete MYSQL tables that match a pattern. Run from the command line

Not terribly safe if you use the password on the cmd line.
mysql -u USER -pPASSWORD dbname -e "show tables" | grep "[0-9A-Z][0-9A-Z]_[0-9A-Z][0-9A-Z][0-9A-Z]_blah" | gawk '{print "drop table " $1 ";"}' | mysql -u USER -pPASSWORD dbname 

Tuesday, June 9, 2009

Change the gain (output volume) of an entire directory of mp3s

find . -iname '*.mp3' -exec mp3gain -r -m +6 -c {} \;

Tuesday, June 2, 2009

Import a csv file (with header line) into mysql with LOAD DATA

LOAD DATA LOCAL INFILE '/home/me/yo.csv' INTO TABLE 1by1_email 
LINES TERMINATED BY "\n"  IGNORE 1 LINES (fields,fields...);