2009-11-17

tar extract single file

Good to know how to extract a single file from a big archive.

List the content of the tar archive

for tar archives
tar -tvf archive.tar

for tar.gz archives
tar -ztvf archive.tar

for tar.bz2 archives
tar -jtvf archive.tar

Then to extract the single file
tar -ztvf archive.tar.gz # to see the whole archive
tar -zxvf archive.tar.gz /root/my/file.txt # to get the file or directory
tar -zxvf archive.tar.gz {path/to/file}

might be wise to use -C target_dir aswell so we dont overwrite it!

2009-11-16

conditional statements mysql

shortie on conditional statements with update. useful!

CREATE TABLE `table` (
`id` int(11) NOT NULL,
`text` varchar(255) default NULL,
`int` int(11) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1


UPDATE table SET `int` = IF(`int`='0','1','0') WHERE id =1