Extract a bzip2 file


To extract data from bzip files use the below.

To extract the file.

bzip2 -d file.bz2

If you want to keep the original file, add the -k option.

bzip2 -dk file.bz2

Use -c option to write out the data.

bzip2 -dc file2.bz2 | grep data
Advertisements

Cut Squid log data


Use the below to cut some data out of squid log that we dont need. Will cut up to the point added in the quotes (”)

From

squidlog.log.18:94.236.109.235 851 - - [28/Sep/2011:19:01:37 +0100] "GET http://someurl HTTP/1.
1" 200 36921 "-" "-" "-" TCP_MISS:SERVER

To

94.236.109.235 866 - - [28/Sep/2011:19:13:57 +0100] "GET someurl HTTP/1.1" 200 38214 "-" "-" "-" TCP_MISS

Using

cut -d ':' -f2,3,4,5,6, squidlog.txt