27 May 2015

How to extract tar.gz file

tar -zxvf file.tar.gz

where, -z works on gzip compression automatically when reading archives; -x, extract archives; -v produce verbose output; -f read the archive from the archive to the specififed file.

How to get the first few lines from the *.gz file.

gzip -cd *.gz | head -n 30
## gzip in a loop
for i in *.gz; do gzip -dk $i; done

Note -d, extraction and k, keep the original file.

blog comments powered by Disqus