Troubles with zip command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Troubles with zip command
# 1  
Old 03-24-2010
Troubles with zip command

Hello,

I have some troubles with script that creates a zip archive.

First I added following command:
Code:
zip -r /path/to/folder/packed_file.zip /another/path/folder_for_packing

But there is a problem: how to zip the folder without adding full path inside the archive?

'folder_for_backing' is not located in the same folder where the script is, so I cannot use this line:
Code:
zip -r /path/to/folder/packed_file.zip folder_for_packing

Using the -j attribute is also not the solution because 'folder_for_packing' contains subfolders and their structure must remain unchanged.

Is there any method to make this thing work?
Thank you.

Last edited by vbe; 03-24-2010 at 02:37 PM.. Reason: use code tags, thank you
# 2  
Old 03-24-2010
What is preventing you from changing directory (cd ...) in your script ?
# 3  
Old 03-24-2010
not perfect answer --just another way

you can execute these commands in ur scriptfile

cd /path/first/folder
zip -r folder1.zip folder
mv folder1.zip /path/second/folder
# 4  
Old 03-24-2010
The move is unnecessary.
Code:
cd /path/first/folder
zip -r /path/second/folder/folder1.zip folder

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Troubles running DB2 command in shell script via cron

Hi there, Now I'm facing error regarding running shell script via cron. The shell script which is required to get value from database. Below is the main part of shell script. #/bin/bash #connect to database(1) db2 connect to $database user xxxx using yyyy #set values from... (3 Replies)
Discussion started by: Rohan Kishibe
3 Replies

2. Shell Programming and Scripting

Question regarding zip command

Hi, I wish to zip a folder with only those files which have ".properties" extension while excluding all other file extensions be it in the same folder or sub-folder. Can you help me with how can get that to work ? (1 Reply)
Discussion started by: mohtashims
1 Replies

3. Shell Programming and Scripting

Zip data using Command

HI Guys, I using below command to zip data but in zip file i have entire path of source. zip $HOME/EM/ZIPData/All.tar.gz /vr/rt/on/mg/set/XM/Swor/xt/0300*.* In Zip file i have entire path vr/rt/on/mg/set/XM/Swor/xt/ I just want file data zip in may target location (2 Replies)
Discussion started by: pareshkp
2 Replies

4. UNIX for Dummies Questions & Answers

How to use zip command in AIX?

hi i am not able to use zip command in aix. getting below error zip abc.zip ksh: zip: not found. oslevel 5.3.0.0 (4 Replies)
Discussion started by: scriptor
4 Replies

5. Shell Programming and Scripting

Zip command not working

Hi, file.txt 1 2 3 4 5 zip command is not working in linux environment. zip file.zip file.txt (5 Replies)
Discussion started by: onesuri
5 Replies

6. Shell Programming and Scripting

Command to zip a directory

Hi , How to compress the entire directory . Rajesh (1 Reply)
Discussion started by: guddu_12
1 Replies

7. UNIX for Dummies Questions & Answers

Serial Command Troubles

Hello, I am trying to send serial commands via a USB->Serial device using Mac OSX 10.5. I have the PL2303 driver installed. I have installed minicom and I can send commands all day long using echo "Dallas" >/dev/tty.usbserial if minicom is running. If minicom is not running the the echo command... (1 Reply)
Discussion started by: Dallasbr
1 Replies

8. UNIX for Dummies Questions & Answers

Zip command (zip folder doesn't include a folder of the same name)

Hi guys, I have a question about the zip command. Right now I have a directory with some files and folders on it that I want to compress. When I run the zip command: zip foo -r I am getting a foo.zip file that once I unzip it contains a foo folder. I want to create the foo.zip, but that... (1 Reply)
Discussion started by: elioncho
1 Replies

9. Shell Programming and Scripting

zip command

Hi All, I have the following requirement. Source file Products_Extract.dat contains <CTRL M > characters and hence is in DOS format. I zip this file using zip command in UNIX BOX as follows: find . -name Products_Extract.dat|zip Target.zip -@ Next I ftp (in Binary MODE) this output zip... (3 Replies)
Discussion started by: sureshg_sampat
3 Replies

10. UNIX for Dummies Questions & Answers

zip command

Hello, What is the appropriate command to zip a folder that contain sub folder and files? Example: Folder lunaa In the folder there are a number of folder e.g 01526, etc...which contains number of file. Any idea would be grateful. Many thanks (1 Reply)
Discussion started by: su_in99
1 Replies
Login or Register to Ask a Question