Sunday, June 10, 2012

Some useful commands and compression utilities on Debian 5


seq 500 > 500.txt


gzip -c 500.txt > 500.txt.gz 


to read this binary zip format(gz files)


zcat 500.txt.gz


to read the output per page basis


zcat 500.txt.gz | less


gzip -l option give the content and stat of the file


example gzip -l 600.txt.gz


similar utility Bzip2


bzip2 -c 600.txt > 600.txt.bz2 


bunzip2 600.txt.bz2


bunzip2 -f 600.txt.bz2(this will overrite the file 600.txt(if present in the 


current directory))


bzcat filename.bz2 will show us the content


for example


bzcat filename.bz2 > content.txt




using zip utility in debian 5.


zip a.txt.zip a.txt


(first the destination and then the source file name)


zip alltxt.zip *txt will zip all the txt files in the curre


unzip a.txt.zip 


unzip -l a.txt.zip to list the contents of the zip file


zcat will also show the content of the zip file


zcat alltxt.zip


unzip -l will show you file by file and zcat will show the contents of the 


file in the zip archive,but zcat will only show the content of the first file 


in the zip archive


so basically zcat works on both zip and gzip




tar utility make a tar archive of files


tar -cvf alltxt.tar *.txt


will create an archive full of all the txt files in the current directory


tar -xvf alltxt.tar will extract those files


tar -tvf alltxt.tar will show the contentof the tar file


du -ch shows the size acclaimed by the all the files in the current directory


to extract a particular file from the tar archive


tar -xvf alltxttar.tar 20.txt


to extract 2 particular file 


tar -xvf alltxttar.tar 20.txt 100.txt




(20.txt is one of the file the alltxt.tar archive)




creating a tar.gz archive


tar -czvf text.tar.gz *.txt


will create an archive named text.tar.gz containing all the text files


the argument has to be czvf,any other combination such as cvzf or cvfz won't 


work




when extracting the z option should be added like 


tar -xvf text.tar.gz


tar -xzvf text.tar.gz




creating tar.bz2 archive named newtest.tar.bz2 containing 


60.txt,70.txt,180.txt


tar -cjvf newtext.tar.bz2 60* 70* 180*




to extract an tar.bz2 archive 


tar -xvf newtext.tar.bz2


tar -xjvf newtext.tar.bz2


to see the content of an tar.bz2 archive


tar -tvf newtext.tar.bz2



No comments:

Post a Comment