f



tar file with . files and . directories

hi

i want to create a tar file with all my . files and . directories in
my home directory.

i cannot create a tar file without having all my files in it
is there a way to create such a tar file?

thanx in advance
cu hausi
0
hausii (1)
3/2/2004 11:00:47 PM
comp.os.linux.misc 33599 articles. 1 followers. amosa69 (78) is leader. Post Follow

8 Replies
1040 Views

Similar Articles

[PageSpeed] 58

On Tue, 02 Mar 2004 23:00:47 +0000, Hannes wrote:

> hi
> 
> i want to create a tar file with all my . files and . directories in my
> home directory.
> 
> i cannot create a tar file without having all my files in it is there a
> way to create such a tar file?
> 
Not very clear what you want to do. If you don't want some files to be
archived, use the -exclude option in tar.
 
-- 

jabali

Please send e-mails to jabali@freeuk.com

0
jabali1 (30)
3/2/2004 11:16:47 PM
hausii@gmx.net (Hannes) writes:

> i want to create a tar file with all my . files and . directories in
> my home directory.

If your homedir is /home/username, then use something like

$ tar cf /tmp/username.tgz /home/username

Don't try something like "cd; tar cf /tmp/username.tgz * .*" because
that will cause problems.

Also, if you do the way I recommended, then your whole home
directory will be under one directory, so if you need to restore it,
it won't cause you problems by creating and possibly clobbering
already existing files.

Vilmos
0
vilmos (163)
3/2/2004 11:32:01 PM
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hannes <hausii@gmx.net> wrote:
> hi

> i want to create a tar file with all my . files and . directories in
> my home directory.

> i cannot create a tar file without having all my files in it
> is there a way to create such a tar file?

$ ls -d .[a-zA-Z0-9]* | tar -cvzf bck-`date -I`.tar.gz -T -

Good luck

- -- 
Michael Heiming (GPG-Key ID: 0xEDD27B94)

Remove +SIGNS and www. if you expect an answer, sorry for 
inconvenience, but I get tons of spam.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFARRm9AkPEju3Se5QRAuVlAKDQn2lxCMZbeDqCuLn0yxRyXnDJtQCgm1+5
Op7tPwkABSzcwdBG1JWPYo0=
=cvXy
-----END PGP SIGNATURE-----
0
USENET22 (5551)
3/2/2004 11:33:18 PM
In article <8c7c0f78.0403021500.2518982b@posting.google.com>,
Hannes <hausii@gmx.net> wrote:
:
:i want to create a tar file with all my . files and . directories in
:my home directory.
:
:i cannot create a tar file without having all my files in it
:is there a way to create such a tar file?

Tar wasn't designed to include a directory without including that
directory's contents.  One way to get the effect you want is to generate
an exclusion list that contains a match for all of the unwanted files
and directories.  Here, this does what I think you want, provided the
current directory does not contain any names with embedded newline
characters:

  ARCHIVE=dotfiles.tar
  touch $ARCHIVE
  find . -maxdepth 1 ! -name '.*' >/tmp/xlist
  tar --exclude-from /tmp/xlist -cvf $ARCHIVE .

The "touch $ARCHIVE" is just there to avoid a harmless diagnostic
message that you would get if you neglected to exclude an archive file
created in the current directory.  (Some old versions of tar would try
to include the archive in itself, with disastrous results.)

-- 
Bob Nichols         AT interaccess.com I am "rnichols"
0
3/3/2004 5:14:55 AM
Hannes <hausii@gmx.net> wrote:
> i want to create a tar file with all my . files and . directories in
> my home directory.

> i cannot create a tar file without having all my files in it
> is there a way to create such a tar file?

    cd && find .??* -depth | cpio -ovH tar > archive.tar

Chris
0
chris-usenet (1132)
3/3/2004 9:26:11 AM
Michael Heiming <michael+USENET@www.heiming.de> wrote:
>
> Hannes <hausii@gmx.net> wrote:
>> hi
>
>> i want to create a tar file with all my . files and . directories in
>> my home directory.
>
>> i cannot create a tar file without having all my files in it
>> is there a way to create such a tar file?
>
> $ ls -d .[a-zA-Z0-9]* | tar -cvzf bck-`date -I`.tar.gz -T -

cd &&
find -name '.[^.]*' -o -name '..?*' -maxdepth 1 | tar -cvf archive.tar -T -

This also allows filenames like .- or ..jaslkfdjdsf.

HTH

Seb
0
hanss (61)
3/3/2004 8:05:37 PM
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sebastian Hans <hanss@in.tum.de> wrote:
> Michael Heiming <michael+USENET@www.heiming.de> wrote:
> >
> > Hannes <hausii@gmx.net> wrote:
> >> hi
> >
> >> i want to create a tar file with all my . files and . directories in
> >> my home directory.
[..]
> > $ ls -d .[a-zA-Z0-9]* | tar -cvzf bck-`date -I`.tar.gz -T -

> cd &&
> find -name '.[^.]*' -o -name '..?*' -maxdepth 1 | tar -cvf archive.tar -T -

 tar -cvzf bck-`date -I`.tar.gz .[a-zA-Z0-9]*

Yep, but then I simply overcomplicated things.
;)

> This also allows filenames like .- or ..jaslkfdjdsf.

Anyone using filenames like that deserves it.

- -- 
Michael Heiming (GPG-Key ID: 0xEDD27B94)

Remove +SIGNS and www. if you expect an answer, sorry for 
inconvenience, but I get tons of spam.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFARj0fAkPEju3Se5QRAtEsAKDTG3zK1ajjgwAtW/yevT57U3oTWwCg1p2I
gS5Au2I49IOfKTNJvcEky7Q=
=Z0cT
-----END PGP SIGNATURE-----
0
USENET22 (5551)
3/3/2004 8:16:33 PM
Michael Heiming <michael+USENET@www.heiming.de> wrote:
> Sebastian Hans <hanss@in.tum.de> wrote:
>> Michael Heiming <michael+USENET@www.heiming.de> wrote:
>> > Hannes <hausii@gmx.net> wrote:
>> >> i want to create a tar file with all my . files and . directories in
>> >> my home directory.
> [..]
>> > $ ls -d .[a-zA-Z0-9]* | tar -cvzf bck-`date -I`.tar.gz -T -
>
>> cd &&
>> find -name '.[^.]*' -o -name '..?*' -maxdepth 1 | tar -cvf archive.tar -T -
>
>  tar -cvzf bck-`date -I`.tar.gz .[a-zA-Z0-9]*
>
> Yep, but then I simply overcomplicated things.
> ;)
>
>> This also allows filenames like .- or ..jaslkfdjdsf.
>
> Anyone using filenames like that deserves it.

Deserves what? Not getting them backed up? Strange filenames are no
excuse for writing scripts that are easily broken. (Assuming that you'll
want to put this in a script.)

Hm. I just noticed: my version doesn't work for filenames containing
newlines.

What the hell. Anyone using filenames like that deserves it.   :-)

Ciao

Seb
0
hanss (61)
3/3/2004 8:40:29 PM
Reply: