This worked for me:
$ tar -czvf test.tar.gz ./file1 ./file2 ...
$ tar -tzf test.tar.gz
# to extract do:
$ tar -xzf test.tar.gz
f option you should give the filename of the archive you are creating.
Oh, and in case you are using
zip to unzip the file, you wont get a directory but you will get a tarball instead. Tarball contains all your files. Use:
tar -xf test
And you should see all your files.
If you'd like to have normal zip files, use
zip command instead of
gz tandem. Also it is a good practice to add correct file suffix:
- tar with gzip (i.e.
tar czvf ...): filename.tar.gz
- tar with bzip2 (i.e.
tar cjvf ...): filename.tar.bz2
- tar without compression (i.e.
tar cvf ...): filename.tar