Archieving question
So I've got an assignment (how true of me :)).
The question is to rearchieve files packed in zip to tar and gzip. So far I got the script to unpack all the files in the provided directory but repacking them back is a little more of a problem. So I've got files as follows: NAME="`basename $FILE`" HEAD=`echo $NAME | cut -d '.' -f1` TAIL=`echo $NAME | cut -d '.' -f2 | tr "[A-Z]" "[a-z]"` so that I could work with the files that end in .zip. The files get unzipped. But I would like to know the logic of how to remove zip archieve and to gzip the unzipped folders (would be great if no ready solution is given) |
The logic is that on Linux the common format for archives is gzipped tar. Working on Linux you will encounter a lot of these archives, which have extension .tar.gz or .tgz. For example most of the source codes are archived in this form and you will find a lot of them referred as "tarballs". Just a suggestion for your task: first manage (create) the tar archive, then take care of the gzip part.
|
Probably it was my confused explanation. The point is not whether I don't know how to use these archievers it is how do I get the name of the folder that was unzipped so I can use gzip to archieve it.
Without that condition it would have been just the question of using grep *.zip | unzip but that way I don't get the name of the unzipped folders. So I thought about something such as local PATH=$1 FILE for i in $PATH/* do HEAD=`echo $FILE | cut -d '.' -f1` TAIL=`echo $FILE | cut -d '.' -f2` if [ $TAIL == "zip" ]; then unzip $FILE fi (yeap not working although could :) work) and the using variable $HEAD to tar -vcf $HEAD Something like that. |
All times are GMT -5. The time now is 05:06 AM. |