tar'ing and zipping files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers tar'ing and zipping files
# 1  
Old 05-02-2006
tar'ing and zipping files

If I have a directory /directory1 and want to tar and zip everything in it into a file new_tar.tar.gz on disk (not tape)

How can I do it?

I tried tar -cv /new_tar.tar /directory1/*

But I got an error: tar: /dev/rmt/0: No such device or address
# 2  
Old 05-02-2006
I would personally never tar anything up with an 'absolute' file name as you'll never know whether you'll have permission to untar it/whether you'll overwrite someone's much needed directory.

I would do the following from directory1:
tar cvf home_directory/new_tar.tar *
# 3  
Old 05-02-2006
Thank you, that tars them up perfectly.

To zip them, should I wait until after they're all tar'red, and then zip, or is there a way to zip as they are tar'ing?
# 4  
Old 05-02-2006
Yes, you can:

tar cf - * | zip_program > tarballname.tar.gz

This is generic, so fill in where appropriate. Some compression programs need a flag to go to standard out so double check.
# 5  
Old 05-02-2006
here ...

tar by the name is "tape archive" so it assumes, if "-f" option wasn't provided it tries to put file on the tape drive: /dev/rmt is a acronym of tape drive in UNIX.

So you give it "-f" option and a file name to redirect archive to file and not to tape.

Today's tar is quite improved so there's no need to use compression as a separate program. Just add "z", like "tar -cvzf". Some versions of tars take the list of parameters without "-" but normally it is required. Get "UNIX Essentials and UNIX Core" DVD or "UNIX in 24 hours" as they teach all this stuff.

Hope it helps.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Find and removing the old files and zipping the files using shell script

Hi, I am trying to removing the old files which were older than 10 days and same g zipping the files using the shell script. script was return as follows. find /jboss7_homes/JBOSS7/SKYLIV??/SKYLIV??_CRM/jboss-eap-7.0/standalone/log -mtime +10 -type f | xargs rm -f find /cer_skyliv??/log... (6 Replies)
Discussion started by: venkat918
6 Replies

2. UNIX for Advanced & Expert Users

Speed problems with tar'ing a 500Gb directory on an eSATA drive

I'm trying to compress a directory structure on an external hard drive, connected by eSATA cable to my linux (Ubuntu 10.04) desktop. The total volume is 500Gb with half a million files, ranging from Kb to Mb in size. The drive is 2Tb, with 0.8Tb free space before compression. running "tar -pcf... (10 Replies)
Discussion started by: omnisppot
10 Replies

3. Shell Programming and Scripting

zipping functionality (tar) not working as expected

Hi all, I here have an index file ($index) which lists the full paths of some files, and am tying to use "tar" to zip all of them. I ran a command like below, cat $index | xargs tar -rcf $archived_file Strangely I noticed only part of files in that index were zipped in my... (4 Replies)
Discussion started by: isaacniu
4 Replies

4. UNIX for Dummies Questions & Answers

Tar-ing folders in a folder

How do I create individual tars of a all the directories in a directory? I have a directory called 'patients', each patient has a directory in the patients directory. I want to create tars such that each patient has their own tar file. Thanks! (5 Replies)
Discussion started by: HappyPhysicist
5 Replies

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

6. Shell Programming and Scripting

grep'ing and sed'ing chunks in bash... need help on speeding up a log parser.

I have a file that is 20 - 80+ MB in size that is a certain type of log file. It logs one of our processes and this process is multi-threaded. Therefore the log file is kind of a mess. Here's an example: The logfile looks like: "DATE TIME - THREAD ID - Details", and a new file is created... (4 Replies)
Discussion started by: elinenbe
4 Replies

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

8. UNIX for Dummies Questions & Answers

Tar-ing the correct directories

Hi all, my directory structure is as follows /a/b/c. I would like to tar the /a directory including the subdirectories b and c. i intend to use the command tar -cvfz a.tgz a/ My question is where do i execute the command? do i execute it at the '/' prompt or at '/a' prompt ? My concern at... (1 Reply)
Discussion started by: new2ss
1 Replies

9. UNIX for Dummies Questions & Answers

tar'ing and regular expressions

Hi, How do I tar all but a specific set of files in a directory? Is it possible to use regular expressions in the tar command? I want to tar all files except those beginning with D. I tried this tar -cvf files.tar ^ but this didn't work. Anyone any ideas. Thanks (2 Replies)
Discussion started by: sirbrian
2 Replies

10. Solaris

Error tar'ing files to tape

I'm trying to tar a bunch of files off to a tape, but for one specific file (it is fairly large, roughly 10Gb) I get the error: too large to archive Does tar have a limit of the size of file it can write off to tape? I'm using SunOS 5.8. Thanks! -Fred (6 Replies)
Discussion started by: FredSmith
6 Replies
Login or Register to Ask a Question