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


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users UNIX: Command to compress folder and all files into a tar
# 1  
Old 01-24-2010
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 file in unix?
# 2  
Old 01-24-2010
looking for
Code:
tar cvf

?
# 3  
Old 01-24-2010
yes i have tried "tar" command with filename but it tells me this:

Tar: blocking factor must be specified with "b" function modifer
Usage: (lists a bunch of modifers)

i do not know what modifer i need in order to compress both the folder and all its contents.

ive also tried what you suggested and it tells me i need a file name... but i have included the file name with that command.
# 4  
Old 01-24-2010
What OS are you using?

Commands have different flags based on the OS.
# 5  
Old 01-24-2010
sun solaris 8
# 6  
Old 01-24-2010
atleast on linux its as simple as

Code:
tar cvf <expected_filename_for_tar_with_dot_tar_extn> <directory>

# 7  
Old 01-24-2010
To also gzip /path/to/somedir with GNU tar use:
Code:
cd /path/to
tar zcvf /var/tmp/somedir.tgz somedir

Otherwise:
Code:
cd /path/to
tar cvf - somedir | gzip > /var/tmp/somedir.tgz

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

HP-UNIX How to zip/compress files in a folder?

Environment: HP-Unix Operating System B.11.31 U ia64 I have a folder with around 2000 files. There are some files which sizes are more than 8 GB. I need to compress all the files in the folder into a single file, so that I can transfer the file. I tried with tar command, but the tar... (8 Replies)
Discussion started by: Siva SQL
8 Replies

2. UNIX for Dummies Questions & Answers

Tar command to preserve the folder/file arrangement

Hi, I do have question for un tar a file. I have several 'tar'ed files. For example: SRS.tar.bz2. I was trying to untar them in a linux server using the command: tar xvjf SRS.tar.bz2 It worked perfectly. but when I open this file in my mac computer all the files are extracted into a... (7 Replies)
Discussion started by: Lucky Ali
7 Replies

3. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

4. Emergency UNIX and Linux Support

Extract particular folder from a .tar format files.

Hi All- I want to extract a particular folder from .tar format files. For example: File Name: backup.tar The backup.tar contains the below folders & files. 1) /root_folder/Folder1/Folder1-1/* 2) /root_folder/Folder1/Folder1-2/* 3) /root_folder/Folder2/Folder2-1/* 4)... (5 Replies)
Discussion started by: k_manimuthu
5 Replies

5. Shell Programming and Scripting

identify files with "Normal termination" and compress them into a .tar.gz file

Hi, I have hundreds of files "*.out" located in one folder, and I want to: 1. Identify the good files containing "Normal termination" (grep "Normal termination" *.out ) 2. Compress the good files into a tar.gz file (tar cvfz good.tar.gz *.goog.out ) Is there a way I can automate this... (4 Replies)
Discussion started by: rockytodd
4 Replies

6. 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

7. UNIX for Dummies Questions & Answers

Issue: Compress in unix server and FTP to windows and open the compress file using Winzip

Hi All ! We have to compress a big data file in unix server and transfer it to windows and uncompress it using winzip in windows. I have used the utility ZIP like the below. zip -e <newfilename> df2_test_extract.dat but when I compress files greater than 4 gb using zip utility, it... (4 Replies)
Discussion started by: sakthifire
4 Replies

8. 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

9. UNIX for Dummies Questions & Answers

unix command to cound the number of files in a folder

Hi All Can some one help me out. Please tell the unix command to cound the number of files in a folder. Ungent please# Thanks manas (6 Replies)
Discussion started by: manas6
6 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