0

I am trying to create a compressed file of sublime text snippets. The snippets I want to include are in the subdirectory snippets of my current directory

All around the web, as far as I can see I should do

tar czf snippets.tar.gz -C snippets .

However, if I do that I get an archive, which looking at it from GNOME Nautilus, shows an archive with a directory named . in it and the files within that directory.

I also tried (and -C snippets/)

tar czf snippets.tar.gz -C snippets *

but then I get the following error

tar: snippets: Cannot stat: No such file or directory tar: snippets.tar.gz: Cannot stat: No such file or directory tar: supporting: Cannot stat: No such file or directory tar: Exiting with failure status due to previous errors

but the directory is definitely there and there doesn't seem anything wrong with its permissions

drwxr-xr-x 2 alan alan 12288 Aug 25 11:15 snippets -rw-r--r-- 1 alan alan 45 Aug 25 11:26 snippets.tar.gz drwxr-xr-x 13 alan alan 4096 Aug 25 09:59 supporting

I'm running debian testing, so I guess there is a possibility that tar is broken at the moment, but I rather doubt it, given the system is so dependant on it. So what am I doing wrong>

3
  • ./ always represents the current directory, it's totally normal. Is this your first meeting with *nix? :-> Aug 25, 2016 at 10:58
  • I have been using *nix for 20 years, but its not correct to have ./ inside the archive I am sure. I've just been able to create an archive how I want it using gnome's file-roller - which is OK for a quick manual update - but I wanted to automate the process via a git-hook and that needs a command line approach.
    – akc42
    Aug 25, 2016 at 11:06
  • Then fill a bugreport for GNOME Nautilus to hide the ./ directory. Aug 25, 2016 at 11:15

1 Answer 1

1

Don't use -C switch when creating tar files. Try it like this:

tar -czf snippets.tar.gz snippets/*

Or something like:

cd snippets;tar -czf ../snippets.tar.gz *;cd ..

You must log in to answer this question.

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