Help with zipping contents but not path


 
Thread Tools Search this Thread
Operating Systems Linux Ubuntu Help with zipping contents but not path
# 1  
Old 11-14-2011
Help with zipping contents but not path

I have a folder, and in this folder, there are about 197 folders.
Resources
a
files and folders
b
files and folders

Like that. I need to make a zip with files and folders in them with the name the same as the parent folder. so.

a.zip
files and folders
b.zip
files and folders

Like that? How would I do that? I cant do it on windows because my intelligence doesn't serve me that well.. and I cant get it on linux either!
# 2  
Old 11-14-2011
If you want all content and subtree of your folder "a" :

Code:
cd "a"
tar cf - . | gzip >a.tgz


You can then move your archive to the desired destination and unzip it like:

Code:
cd destination
gunzip -c a.tgz | tar -xf -

From the man pages :
Gzip uses the Lempel-Ziv algorithm used in zip and PKZIP.
# 3  
Old 11-14-2011
I need to do 200 directories though... can you write me a script?

---------- Post updated at 02:21 AM ---------- Previous update was at 02:19 AM ----------

I know how to do it manually, I need to know how to do 200 directories with a script. or something. I cant be asked to run 200 seperate commands. its just un-kosher

---------- Post updated at 02:22 AM ---------- Previous update was at 02:21 AM ----------

also, it needs to use .zip. Nothing else!
# 4  
Old 11-14-2011
If there are 200 directories inside your directory "a", all of them will be included in the archive generated by the command previously given (assuming your user is granted to see them).

Why such a restriction regarding "zip" format ? by the way, as previously specified (extract from man page), gzip works with the same compression algorithm, so you should be able to rename the file in *.zip if you wish (i haven't tried it but i suppose it should work), but you would then have to deal with the tar format.

There are some free program like 7zip that works for windows as well and are able to manage such files.
# 5  
Old 11-14-2011
Like. in the folder X there are 200 folders. Inside each of those 200 folders, I need the content from folder 1, into a zip. 1.zip
then content from folder 2. 2.zip. it cant have the folder 1 in the root of that zip though. it has to have the CONTENT in the first part? This is very confusing. I know.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Zipping

Good Morning, I'd like to archive an old user's files in the home directory on Solaris 9 Will this work? cd home tar -zcvf jsmitharchive.tar.gz jsmith/ ---------- Post updated at 09:37 AM ---------- Previous update was at 09:33 AM ---------- Also- is the last /necessary (after... (4 Replies)
Discussion started by: Stellaman1977
4 Replies

2. Shell Programming and Scripting

How to print contents of file when the file path is in a variable?

The file f1 contains the text "body" (shell prompt is "$"): $ cat ~/path/f1 body How to print contents of f1 when the f1 path is in a variable? Here is my failed attempt: $ f1="~/path/f1" $ echo $f1 ~/path/f1 $ cat $f1 cat: '~/path/f1': No such file or directory (2 Replies)
Discussion started by: wolfv
2 Replies

3. UNIX for Advanced & Expert Users

Command to see the logical volume path, device mapper path and its corresponding dm device path

Currently I am using this laborious command lvdisplay | awk '/LV Path/ {p=$3} /LV Name/ {n=$3} /VG Name/ {v=$3} /Block device/ {d=$3; sub(".*:", "/dev/dm-", d); printf "%s\t%s\t%s\n", p, "/dev/mapper/"v"-"n, d}' Would like to know if there is any shorter method to get this mapping of... (2 Replies)
Discussion started by: royalibrahim
2 Replies

4. Shell Programming and Scripting

Zipping contents without the actual directory

Hi , I want to zip files present in the directories listed under a parent directory without zipping the directory itself my parent directory path is /informatica/DGDMN/PowerCenter1011/server/infa_shared/SrcFiles/OTE/Final_Directory I have the below directories named as 1,2,3,4,5 listed... (9 Replies)
Discussion started by: paul1234
9 Replies

5. Shell Programming and Scripting

If contents of A are in B then move the common contents to C

Hallo Team, I have 2 .csv files file A has 47600 lines and file B has 67000 lines FILEA SD0o9rb01-1d320ddbcc8d220f572739ebed5f58d1-v300g00 SD8bt0101-a0810bfe0e3396060126ec51b30dac0a-v300g00 SD05sce01-cb056af347ed4651f29eb3c3e9addbd6-v300g00... (3 Replies)
Discussion started by: kekanap
3 Replies

6. Shell Programming and Scripting

Folder contents getting appended as strings while redirecting file contents to a variable

Hi one of the output of the command is as below # sed -n "/CCM-ResourceHealthCheck:/,/---------/{/CCM-ResourceHealthCheck:/d;/---------/d;p;}" Automation.OutputZ$zoneCounter | sed 's/$/<br>/' Resource List : <br> *************************** 1. row ***************************<br> ... (2 Replies)
Discussion started by: vivek d r
2 Replies

7. Shell Programming and Scripting

Help with zipping files

Hi, I have come across a requirement in which I need to zip files. This is fine but the requriement has one conditions like below: One .z file can not have more than 10,000 files Now in the directory I have several files liek below: aaa_file_10_00001.txt aaa_file_10_00002.txt... (6 Replies)
Discussion started by: angshuman
6 Replies

8. Shell Programming and Scripting

zipping files

Hi, Is there any difference if files are individually zipped and archived in a directory or if files are moved into archiving directory and zipping that directory. (3 Replies)
Discussion started by: swathich
3 Replies

9. UNIX for Advanced & Expert Users

Help me While zipping the file

Hi , I have written code which will ask the subject,body of the mail, attachment and mail id of the receipient. Code will pick up 4 files zip it. It will zip all the files and then post the mail to the receipient. While zipping the file i am getting error. Can anyone help me with this. ... (7 Replies)
Discussion started by: Jolly
7 Replies

10. UNIX for Dummies Questions & Answers

Zipping

Hi In unix i want to zip the files in a directory excluding *.dmp, *.log, *.lst, *.out files in that directory. pls let me know what command to use. $zip ........ ? Thanks (1 Reply)
Discussion started by: dreams5617
1 Replies
Login or Register to Ask a Question