Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to archive 3 folders, given their names in Ubuntu command prompt.
When I use tar -c abc tt zz -> it will do nothing.

share|improve this question
    
both answers are good, I wish I could accept both – Floradu88 Jan 15 '12 at 11:02
up vote 5 down vote accepted

You either need to redirect that output to your tarball name as in:

tar -c abc tt zz > tarball.tar

(Careful, that will overwrite tarball.tar if it's already there) or you need to use the -f flag for tar and specify a filename as in:

tar -cf tarball.tar abc tt zz
share|improve this answer
    
how about the use of gz? – Floradu88 Jan 15 '12 at 10:57
3  
if you add the -z flag to the tar command it will tell it to use gzip compression (e.g. tar -czf tarball.tar.gz abc tt zz), -j will use bzip2 (e.g. tar -cjf tarball.tar.bz2 abc tt zz). The way that tar handles it's output is the same whether or not compression is used. Without the -f it goes to stdout. – d34dh0r53 Jan 15 '12 at 11:01

You can use this command

 tar -cvzf tarname.tar.gz a b c

eg:

x@x:/tmp/aas$ touch a b c
x@x:/tmp/aas$ ls
a  b  c
x@x:/tmp/aas$ tar cvzf tarname.tar.gz a b c
a
b
c
x@x:/tmp/aas$ ls
a  b  c  tarname.tar.gz
x@x:/tmp/aas$ rm a b c
x@x:/tmp/aas$ ls
tarname.tar.gz
x@x:/tmp/aas$ gunzip -c tarname.tar.gz | tar xvf -
a
b
c
x@x:/tmp/aas$ ls
a  b  c  tarname.tar.gz
x@x:/tmp/aas$ 
share|improve this answer
    
how about the use of gz? – Floradu88 Jan 15 '12 at 10:56
1  
this will tar and gzip it in a single command. If you wish you can do it seperately as well – daya Jan 15 '12 at 10:58
    
The link is broken – Justin 2 days ago

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .