tar and compress in one step


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting tar and compress in one step
# 1  
Old 12-07-2010
tar and compress in one step

I know there is a way to tar up directory and sub-directories and have it compressed all in one command but but the syntax escapes me.

I seem to re-call something like this:

tar -cvf /tmp/file.tar - | compress ?

Can somebody please provide me with the syntax on how to tar/compress
and untar/de-compress all in one step

Thanks
# 2  
Old 12-07-2010
Do you mean tar Zcvf ... ?
(or tar zcvf or tar jcvf for gzip/bzip2)?
# 3  
Old 12-07-2010
Just want the filed in "compress" format. Or to clarify, it I were to do it
in two steps this would be the second step

compress file.tar
# 4  
Old 12-07-2010
Code:
tar -cvf tarName.tar /path/*        # to tar all files and directories and sub directories in /path directory

tar -cvf tarName.tar `cat fileName`      # to tar specific files listed in "fileName" file

=================================

tar -xvf tarName.tar            # to untar the "tarName.tar" file

==================================

tar -tvf tarName.tar       # to see content of "tarName.tar"

R0H0N
# 5  
Old 12-07-2010
Quote:
Originally Posted by BeefStu
Just want the filed in "compress" format. Or to clarify, it I were to do it
in two steps this would be the second step

compress file.tar
Try Zcvf if you have GNU tar...
# 6  
Old 12-07-2010
Quote:
Originally Posted by R0H0N
Code:
tar -cvf tarName.tar /path/*        # to tar all files and directories and sub directories in /path directory
 
tar -cvf tarName.tar `cat fileName`      # to tar specific files listed in "fileName" file
 
=================================
 
tar -xvf tarName.tar            # to untar the "tarName.tar" file
 
==================================
 
tar -tvf tarName.tar       # to see content of "tarName.tar"

Thanks for the resonse, I know how to use tar, I want to be able to tar and compress in one step

---------- Post updated at 08:51 AM ---------- Previous update was at 08:50 AM ----------

Quote:
Originally Posted by Scrutinizer
Try Zcvf if you have GNU tar...
I don't have GNU tar, this is just a plain AIX system. But thanks anyway
# 7  
Old 12-07-2010
Code:
tar cf - some_dir | compress -c > /tmp/some_dir.tar.Z

and uncompress with:
Code:
compress -cd /tmp/some_dir.tar.Z | tar xf -

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compress a tar file to smaller size

I have a tar file with name DTT012_GP_20140207.tar and many more with different names of different sizes ranging from 1GB to 4GB. Now my requirement is to extract/not extract these files and then divide it into various parts of size 500MB and save it with different names and then compress... (5 Replies)
Discussion started by: Shaibal_bp
5 Replies

2. UNIX for Dummies Questions & Answers

Compress 1st 20 Large different File using tar

Sorry guys.. dont know where to put this.. currently I am cleaning up system dump on our aix machine and I wanted to set zero the 1st 20 large file but before doing that I wanted to create some backup. is there any command that can compress all these file same time? tar syntax file? ... (2 Replies)
Discussion started by: thermometer
2 Replies

3. Shell Programming and Scripting

Archive directory script with tar/compress

Hi all I need to write a script that archives all files with a certain date in the filename, to another location. It has to run on a AIX using tar/compress or another standard AIX tool. The directory will have x files, each prefixed with a date like yyyymmdd_desc.csv. I need all to... (7 Replies)
Discussion started by: AIXfrog
7 Replies

4. UNIX for Advanced & Expert Users

UNIX: Command to compress folder and all files into a tar

I am trying to grab a folder and all the folders and files underneath it and send it from one computer to another. I basically want to compress the whole folder into a tar, tgz, or zip file so that it can be sent as one file. is there a command to compress a folder and all its contents into a tar... (7 Replies)
Discussion started by: kane4355
7 Replies

5. UNIX for Dummies Questions & Answers

Compress the file using Tar command

Hi, When i am tar the file particular ,csv file format in a folder i am receiving the error Command: tar cf New_data.tar /new/file/mari/getdata/small/*.xml Arguements too long But sometimes i am able to compress other folder but the tar folder contains all the file format and... (10 Replies)
Discussion started by: marivinay
10 Replies

6. Shell Programming and Scripting

How to tar, compress and remove files older than two days

Hi, I'm Eddy from Belgium and I've the following problem. I try to write a ksh script in AIX to tar, compress and remove the original *.wav files from the directory belgacom_sf_messages older than two days with the following commands. The problem is that I do not find a good combination... (4 Replies)
Discussion started by: edr
4 Replies

7. Shell Programming and Scripting

compress directories with .tar extension

hi guys.. Since am a bit new to shell scripting, can anyone help me with this problem please.. i've been struggling with it since 2 days. :( I have a directory lets say myFolder and within it I have sub directories let say myFolder1.tar, myFolder2, myFolder3, etc. I need to write a shell... (12 Replies)
Discussion started by: kanexxx
12 Replies

8. Shell Programming and Scripting

Search, Tar and Compress in one line

Hi all, I am supposed to collect a huge amount of log files from a unix system (HP-UX) onto a local system. The log files are not in one place, but they are scattered all over the Unix server. The unix server has only limited space, so that I can not create a tar file first and then compress it.... (4 Replies)
Discussion started by: bluesky099
4 Replies

9. UNIX for Advanced & Expert Users

tar and compress

I need to compress and tar a couple files in a directory, but I also want the original files unchanged, ie if I compress a1.cpp , then a1.cpp becomes a1.cpp.z, but what I want after running the compress utility is to have both a1.cpp as it is and a1.cpp.z and then tar a1.cpp.z to an... (4 Replies)
Discussion started by: muru
4 Replies

10. UNIX for Dummies Questions & Answers

tar command with compress option...

Hi ! i have to write a script that archivs homes not used since 3 years. First, my script gathers the users that are concerned, using the following command : ll -lt /home/*/.sh_history | egrep '2000|1999|1998|1997' | awk '{print $3}' i obtain a list like this : user_1 user_2 ...... (3 Replies)
Discussion started by: tomapam
3 Replies
Login or Register to Ask a Question