Zipping contents without the actual directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Zipping contents without the actual directory
# 8  
Old 09-13-2017
Moderator's Comments:
Mod Comment Seriously: DO NOT edit a post if others have already answered / referred to it, pulling the rug from under their feet!
# 9  
Old 09-13-2017
Hi Ravinder /Rudic
I am using Unix operating system . I have mentioned my scenario in my first post itself along with the code . Can you please help ?

Regards,
Sankalp
# 10  
Old 09-14-2017
When you say zipping, do you mean the process of:-
  • compressing the data of a single file?
  • bunching up lots of files into a single archive?
  • both at the same time?

Something like tar collects multiple files and puts them into a single convenient archive. Depending on your OS, you might have the -z which will compress them at the same time with gzip It is customary to use a file extension such as .tar.gz or .tgz for such compressed archives.

If you don't have the -z flag, then writing to STDOUT and then piping that through gzip or compress (depending what you have available) can then be directed to a single file.

Have a try with these to see what you can do:-
Code:
cd /path/to/source/directory
tar -czvf /path/to/my_data.tgz  .
tar -cvf - . | compress > /path/to/my_data.tar.Z
tar -cvf - . | gzip > /path/to/my_data.tar.gz

I hope that this helps,
Robin

Last edited by rbatte1; 09-14-2017 at 01:07 PM.. Reason: Made a bullet list
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Zipping the logs of directory

Hi Folks, I have logs at the following location cd /out/app/logs/ now that logs directory contain different types of logs now sometimes i need to do disk clean up activity so i need to zipped the logs can you please advise any command by which all the logs created in this directory are... (2 Replies)
Discussion started by: punpun66
2 Replies

2. UNIX for Dummies Questions & Answers

Deleting a directory and zipping another directory

Hi Folks, I have a directory in unix that is /usr/local/pos contain the folowing directoreis ..that is dir1 dir2 dir3 now I want to delete only dir2 please advise how to remove the directory dir 2 ..that is rm command and how to use it , and second if I want to zip the dir3 please... (1 Reply)
Discussion started by: punpun66
1 Replies

3. Shell Programming and Scripting

Catching the xml tag when only parent directory is known ..not the actual directory

Hi folks, I have an query that is let say i have to search in an xml file an tag that is <abcdef> now this xml file is at /opt/usr/local so one fastest way to achieve this is go to this location by cd /opt/usr/local and then do grep like this... grep -i abcdef but for this I must know the... (4 Replies)
Discussion started by: punpun66
4 Replies

4. Shell Programming and Scripting

Zipping a directory and extracting to another server.

Hello everyone, I am trying to make a script in KSH that will zip an entire directory but leave out one file in that directory. I then need to send that zipped directory to another UNIX box. I am new to UNIX and would appreciate a good template to study from. (3 Replies)
Discussion started by: BrutalBryan
3 Replies

5. Ubuntu

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... (4 Replies)
Discussion started by: austech360
4 Replies

6. Shell Programming and Scripting

Zipping of file in a different directory

Hi, I am having some problem with a shell script which zip some files. For zipping I have used the following command: find . -name "Test_*" -mtime 0 | zip Test_$(date +"%Y%m%d") -@ I have kept the script in /home/abc directory. It is creating the zip file within the same directory where i... (2 Replies)
Discussion started by: abhishek_510
2 Replies

7. Shell Programming and Scripting

zipping a directory when the file count is over $X

Hiya, I've been plugging away at this script and I cant get it to behave as I need. first off it fails to adhere to the conditions of the file limit, and zips the directory regardless of the file count and secondly, but less important it zips up the entire path not just the directory I'm... (2 Replies)
Discussion started by: orionrush
2 Replies

8. Shell Programming and Scripting

Remove contents of directory, but not directory

What's the best way to delete everything in a directory, but not the directory itself, without using shell wildcards? (9 Replies)
Discussion started by: pdc
9 Replies

9. UNIX for Dummies Questions & Answers

zipping all the tar files to singlr file in directory

Hi, i have more than 300 tar files in directory and i want to zip all tar files to single file. could anybody tell me the command since i know how to do zip for single tar file: bash-3.00$gzip 2008_11_10.tar bash-3.00$ pwd /oracle1/archivebackup in this directory i have lot files... (2 Replies)
Discussion started by: prakash.gr
2 Replies

10. Shell Programming and Scripting

determining actual directory of a symlinked directory

Hello all, I have files at /var/dir1/dir2/fil1.log etc.,. dir2 is symlinked to /export/xxx/dir3 I am trying to monitor the disk space of the mount where these log files are present. How do I determine dynamically the actual directory of the log files and corresponding mount when I use df... (3 Replies)
Discussion started by: chiru_h
3 Replies
Login or Register to Ask a Question