Thursday, November 27, 2008

MySQL: Load CSV into db

DROP TABLE IF EXISTS `digitalsignage`.`tmp_directory`;
CREATE TABLE `digitalsignage`.`tmp_directory` (
`f1` varchar(255) NULL,
`f2` varchar(255) NULL,
`f3` varchar(255) NULL,
`f4` varchar(255) NULL,
`f5` varchar(255) NULL,
`f6` varchar(255) NULL,
`f7` varchar(255) NULL,
`f8` varchar(255) NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

LOAD DATA INFILE 'Book2.csv'
INTO TABLE `tmp_table`
FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '\\'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES;

Thursday, November 20, 2008

pgsql rename table

ALTER TABLE products RENAME TO items;

Wednesday, November 19, 2008

linux disk usage

du -B MB --max-depth=1 |sort -nr

Wednesday, November 12, 2008

linux sort

sort a tab delimited file: on column 2 (where you have column 1,2,3...)

sort -t$'\t' +1 -2 export_1612.txt>sorted.txt

Friday, November 07, 2008

BASH - Time Your Bash Script

#!/bin/bash
time_start=`date +%s`
sleep 63
time_end=`date +%s`
time_elapsed=$((time_end - time_start))
echo $(( time_elapsed / 60 ))m $(( time_elapsed % 60 ))s

Tuesday, November 04, 2008

VMWare on supporting 64 bit guest OSes

I wanted to play with a 64 bit OS once, so I installed VMWare to experiment with it. My box had a 64 bit AMD CPU, and was running a 32 bit linux OS on it. I didn't think I would be able to install a 64 bit VMWare guest OS on it, but it worked fine.

Later I tried this all again but on an intel 32 bit box, and it didn't work.

I just found a link that describes under exactly what conditions 64 bit guest OSes will and won't work:[kb.vmware.com].