LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-29-2007, 09:10 AM   #1
Breezend
LQ Newbie
 
Registered: Dec 2006
Posts: 4

Rep: Reputation: 0
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)
 
Old 10-29-2007, 09:32 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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.
 
Old 10-29-2007, 12:07 PM   #3
Breezend
LQ Newbie
 
Registered: Dec 2006
Posts: 4

Original Poster
Rep: Reputation: 0
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Question, Apples Contribution to Open Source + MacOs file structure question Higgy3k Other *NIX 5 07-25-2005 04:23 AM
Not your regular GRUB question - just a short question for a fried MBR!! ziphem Linux - General 3 01-31-2005 01:51 PM
login prompt question & kde scheme question JustinCoyan Slackware 2 06-09-2004 02:02 PM
RE: Suse 8.0 hardware question {newbie question, pls help} Radiouk Linux - Distributions 2 06-04-2002 12:53 PM
Lilo/kernel question & font question phek Linux - General 9 09-18-2001 12:20 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration