|
|
| GNU Tar on Windows XP |
  United States |
2008-03-01 18:51:23 |
I'm trying to see if I can use gnu tar to recreate an
existing
directory structure, without all the files.
If I nav to a folder in Explorer and create a new folder
called "TOP",
then go into TOP and create "MIDDLE" and
then go into MIDDLE and create "BOTTOM"; and leave
them emtpy.
then I go back up to TOP and use
tar -c -f MyDir-Stru.tar TOP/* it creates an archive just
fine, no
grumbling
J:Temp FolderswbtTemp>tar -c -f MyDir-Stru.tar Top/*
J:Temp FolderswbtTemp>dir *.tar
Volume in drive J is Big Hard Drive
Volume Serial Number is C04F-2C92
Directory of J:Temp FolderswbtTemp
03/01/2008 04:45 PM 10,240 MyDir-Stru.tar
1 File(s) 10,240 bytes
0 Dir(s) 142,089,994,240 bytes free
J:Temp FolderswbtTemp>tar -t -v -f MyDir-Stru.tar
drwsrwsrwx user/group 0 2008-03-01 15:41 Top/Middle/
drwsrwsrwx user/group 0 2008-03-01 15:41
Top/Middle/Bottom/
I can now use -x and recreate the folder structure !!! Nice
!!!
*** However ***
if I use
J:Temp FolderswbtTemp>tar -c -f Test.tar | find Top !
-type f
tar: Cowardly refusing to create an empty archive
Try `tar --help' for more information.
Top
TopMiddle
TopMiddleBottom
tar gives up and won't create the archive. Am I doing
something
wrong ? Just not possible ?
I'm using...
J:Temp FolderswbtTemp>tar --version
tar (GNU tar) 1.12
is there a newer Windows binary out there ?
|
|
| Re: GNU Tar on Windows XP |
  United States |
2008-03-01 19:04:41 |
I'm sorry I posted the wrong command above...
J:Temp FolderswbtTemp>tar -c -f MDSTop.tar Top
J:Temp FolderswbtTemp>tar -t -v -f MDSTop.tar
drwsrwsrwx user/group 0 2008-03-01 16:44 Top/
drwsrwsrwx user/group 0 2008-03-01 15:41 Top/Middle/
drwsrwsrwx user/group 0 2008-03-01 15:41
Top/Middle/Bottom/
creates the same archive with only 3 folders in it.
|
|
| Re: GNU Tar on Windows XP |

|
2008-03-01 21:23:01 |
Gadrin wrote:
> if I use
> J:Temp FolderswbtTemp>tar -c -f Test.tar | find
Top ! -type f
> tar: Cowardly refusing to create an empty archive
> Try `tar --help' for more information.
> Top
> TopMiddle
> TopMiddleBottom
>
> tar gives up and won't create the archive. Am I doing
something
> wrong ? Just not possible ?
Yes, you are doing something silly. The -c
option creates an
archive. You are telling tar with 'tar -c -f Test.tar' to
create a
tar archive Test.tar. But you didn't give it any file
arguments on
the command line.
And you are piping that into find which doesn't make sense
to me
either. The find comand will find files and take an action
such as
outputing the name or other things but doesn't make sense
receiving
whatever input was going to go into it there.
You probably wanted to do something like this:
tar -c -f Test.tar `find Top -type d`
Except that requires a unix like command shell and your
message showed
you using the MS command.com and this won't work there. It
would work
in bash but not in command.com. You might be able to use
bash for the
command line like this. I have not tried it.
bash -c "tar -c -f Test.tar `find Top -type d`"
Bob
|
|
| Re: GNU Tar on Windows XP |

|
2008-03-02 08:58:32 |
|
Hi, thanks for responding.
I was going off of http://forums12.itrc.hp.com/service/forums/questionanswer.do?admit=109447627+1204469251779+28353475&threadId=1178036
The difference being the "." (dot) to match everything. However in gnu tar, I'm able to use a single directory when I type in the command line as I mentioned
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
J:Temp FolderswbtTemp>tar -c -f Top.tar Top
J:Temp FolderswbtTemp>tar -t -v -f Top.tar drwsrwsrwx user/group 0 2008-02-29 21:16 Top/ drwsrwsrwx user/group 0 2008-02-29 21:16 Top/Middle/
drwsrwsrwx user/group 0 2008-02-29 21:16 Top/Middle/Bottom/
J:Temp FolderswbtTemp>
It creates the archive just fine, when I reference only "Top" as the file or input argument. However the problem is that gnu tar won't take the piped arguments from the find command
to build a similar archive. I want to be able to "do it on the fly" meaning I don't have to build an empty dir structure then build the archive.
In the meantime I've found a alternative method, which isn't so bad...
(Just substitue Writing for Top as a folder in the following)
J:Temp FolderswbtTemp>xcopy c:writing "J:Temp FolderswbtTempwriting" /t /e :<-- creates an empty/temporary structure J:Temp FolderswbtTemp>tar -c -f Writing.tar writing '<-- creates an archive of the dir structure
J:Temp FolderswbtTemp>tar -t -v -f Writing.tar ;<--- shows all folders J:Temp FolderswbtTemp>rd /q /s writing ;<--- removes the blank/temporary structure.
I was hoping there was a way to pipe the folder names to tar, but so far no joy.
Jay
On Sat, Mar 1, 2008 at 7:23 PM, Bob Proulx < bob  proulx.com ">bob proulx.com> wrote:
Gadrin wrote:
> if I use
> J:Temp FolderswbtTemp>tar -c -f Test.tar | find Top ! -type f
> tar: Cowardly refusing to create an empty archive
> Try `tar --help'; for more information.
> Top
> TopMiddle
> TopMiddleBottom
>
> tar gives up and won't create the archive. Am I doing something
> wrong ? Just not possible ?
Yes, you are doing something silly. The -c option creates an
archive. You are telling tar with 'tar -c -f Test.tar39; to create a
tar archive Test.tar. But you didn't give it any file arguments on
the command line.
And you are piping that into find which doesn't make sense to me
either. The find comand will find files and take an action such as
outputing the name or other things but doesn't make sense receiving
whatever input was going to go into it there.
You probably wanted to do something like this:
tar -c -f Test.tar `find Top -type d`
Except that requires a unix like command shell and your message showed
you using the MS command.com and this won't work there. It would work
in bash but not in command.com. You might be able to use bash for the
command line like this. I have not tried it.
bash -c "tar -c -f Test.tar `find Top -type d`"
Bob
-- Thanks, Gadrin
|
| Re: GNU Tar on Windows XP |
  United States |
2008-03-02 08:59:44 |
Hi, thanks for responding.
I was going off of
http://forums12.itrc.hp.com/service/forums/questiona
nswer.do?admit=109447627+1204469251779+28353475&threadId
=1178036
The difference being the "." (dot) to match
everything. However in gnu
tar, I'm able to use a single directory when I type in the
command line as I mentioned
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
J:Temp FolderswbtTemp>tar -c -f Top.tar Top
J:Temp FolderswbtTemp>tar -t -v -f Top.tar
drwsrwsrwx user/group 0 2008-02-29 21:16 Top/
drwsrwsrwx user/group 0 2008-02-29 21:16 Top/Middle/
drwsrwsrwx user/group 0 2008-02-29 21:16
Top/Middle/Bottom/
J:Temp FolderswbtTemp>
It creates the archive just fine, when I reference only
"Top" as the
file or input argument.
However the problem is that gnu tar won't take the piped
arguments
from the find command
to build a similar archive. I want to be able to "do it
on the fly"
meaning I don't have to build
an empty dir structure then build the archive.
In the meantime I've found a alternative method, which isn't
so bad...
(Just substitue Writing for Top as a folder in the
following)
J:Temp FolderswbtTemp>xcopy c:writing "J:Temp
FolderswbtTemp
writing" /t /e :<-- creates an empty/temporary
structure
J:Temp FolderswbtTemp>tar -c -f Writing.tar writing
'<--
creates an archive of the dir structure
J:Temp FolderswbtTemp>tar -t -v -f Writing.tar
;<---
shows all folders
J:Temp FolderswbtTemp>rd /q /s writing
;<---
removes the blank/temporary structure.
I was hoping there was a way to pipe the folder names to
tar, but so
far no joy.
Jay
|
|
| Re: GNU Tar on Windows XP |

|
2008-03-02 15:22:35 |
Gadrin wrote:
> I was going off of
> http://forums12.itrc.hp.com/service/forums/questiona
nswer.do?admit=109447627+1204469251779+28353475&threadId
=1178036
>
> The difference being the "." (dot) to match
everything. However in
> gnu tar, I'm able to use a single directory when I type
in the
> command line as I mentioned
In a regular expressoin "." matches any character
but in the thread
you reference "." is used in a file context not a
regular expression
context. In a file context "." indicates the
current directory. In
Unix filesystems every directory has two special entries.
"." is the
current directory and links to itself. ".." is
the parent directory
and links upward.
So in the context above given to tar as a file "."
means the current
directory and tar will recursively travel the current
directory
downward archiving what it finds. This is the same as when
you give
tar "Top" and it recurses down that directory.
Both are named
directories to tar.
> It creates the archive just fine, when I reference only
"Top" as the
> file or input argument. However the problem is that
gnu tar won't
> take the piped arguments from the find command to build
a similar
> archive.
But you were not piping from find into tar. You were piping
from tar
into find. You were doing the opposite of what you thought
you were
doing.
> I want to be able to "do it on the fly"
meaning I don't
> have to build an empty dir structure then build the
archive.
Sure. I tried to suggest something that might work for you.
However
my experience is with unix systems and not ms systems and
therefore I
don't know if it will actually work on your ms system.
> In the meantime I've found a alternative method, which
isn't so bad...
>
> (Just substitue Writing for Top as a folder in the
following)
>
> J:Temp FolderswbtTemp>xcopy c:writing
"J:Temp FolderswbtTempwriting"
> /t /e :<-- creates an empty/temporary structure
Whatever you say. I don't do windows.
> J:Temp FolderswbtTemp>tar -c -f Writing.tar
writing '<-- creates an
> archive of the dir structure
> J:Temp FolderswbtTemp>tar -t -v -f Writing.tar
;<--- shows all
> folders
You can avoid the second pass by adding the 'v' option to
the first
invocation of tar. Then you would see the verbose table of
contents
as the archive is created and could avoid making a second
pass over
the data.
> I was hoping there was a way to pipe the folder names
to tar, but so far no
> joy.
Did you see my previous suggestion?
bash -c "tar -c -f Test.tar `find Top -type d`"
Seems like it should work to me but I can't test it on your
system.
Bob
|
|
| Re: GNU Tar on Windows XP |
  United States |
2008-03-02 17:22:03 |
>Well, that is better but still won't work. Find
produces a list of
>directories okay but tar doesn't have code to read them
from stdin.
ah ! thanks.
okay I piped FIND's output to a .txt file and used -T
Top-Dir.txt as
the input and thar she blows ! Extract works. I thought tar
could
read from stdin.
guess I got carried away with this from the manual:
$ find dir tests |
tar -cf archive -T - --no-recursion
Okay, I've got 2 work-arounds.
|
|
| Re: GNU Tar on Windows XP |

|
2008-03-02 20:36:54 |
Gadrin wrote:
> guess I got carried away with this from the manual:
>
> $ find dir tests |
> tar -cf archive -T - --no-recursion
That is even better. *I* didn't know about the -T option.
It is not
in the traditional legacy tar but is a cool GNU extension.
The "-" in
this case is a traditional name for stdin/stdout. So this
does read
the file list from stdin.
Bob
|
|
| Re: GNU Tar on Windows XP |
  United States |
2008-03-02 22:13:32 |
On Mar 2, 6:36 pm, b... proulx.com (Bob Proulx) wrote:
> Gadrin wrote:
> > guess I got carried away with this from the
manual:
>
> > $ find dir tests |
> > tar -cf archive -T - --no-recursion
>
> That is even better. *I* didn't know about the -T
option. It is not
> in the traditional legacy tar but is a cool GNU
extension. The "-" in
> this case is a traditional name for stdin/stdout. So
this does read
> the file list from stdin.
>
> Bob
Yes, and no.
Yes it does read from the stdin but the problem is that it
seems to be
ignoring
the fact I only want folders.
J:Temp FolderswbtTemp>find c:writingwinbatch -type d
c:writingwinbatch
c:writingwinbatch2007-Tutorial
c:writingwinbatch2007-TutorialAccess
c:writingwinbatch2007-TutorialExcel
c:writingwinbatch2007-TutorialMSIE
c:writingwinbatch2007-TutorialWeb
c:writingwinbatchHomeCare
c:writingwinbatchMYSQL
lists all folders, however when tar gets a-hold of them, it
thinks I
want their
contents. It fills the archive with ALL the files in those
folders.
That's the
Windows Command Interpreter obviously.
Obviously on that page I posted it seemed to work
http://forums12.itrc.hp.com/service/forums/questiona
nswer.do?admit=109447627+1204517542565+28353475&threadId
=1178036
do you get only folders and the structure (no files) on a
test on your
system ?
|
|
| Re: GNU Tar on Windows XP |
  United States |
2008-03-02 22:19:09 |
or better yet, is it possible to only extract the
folders/directories ?
|
|