PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > is there a cp argument that preserves directory structure
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

is there a cp argument that preserves directory structure

Réponse
 
LinkBack Outils de la discussion
Vieux 23/05/2007, 06h46   #1
Ben
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut is there a cp argument that preserves directory structure

e.g. file: ./a/b/c/a.txt
I wanna cp file to a another directory, while mkdir'ing a/b/c/ if
neccessary, can that be done?

Regards

  Réponse avec citation
Vieux 23/05/2007, 07h02   #2
Jean-Rene David
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: is there a cp argument that preserves directory structure

* Ben [2007.05.23 05:46]:
> e.g. file: ./a/b/c/a.txt
> I wanna cp file to a another directory, while mkdir'ing a/b/c/ if
> neccessary, can that be done?


pax -r -w ./a/b/c/a.txt directory

--
JR
  Réponse avec citation
Vieux 23/05/2007, 13h49   #3
Kenny McCormack
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: is there a cp argument that preserves directory structure

In article <s42dnfTHFtJnRc7bnZ2dnUVZ_q2pnZ2d@magma.ca>,
Jean-Rene David <jrdavid@magma.ca> wrote:
>* Ben [2007.05.23 05:46]:
>> e.g. file: ./a/b/c/a.txt
>> I wanna cp file to a another directory, while mkdir'ing a/b/c/ if
>> neccessary, can that be done?

>
>pax -r -w ./a/b/c/a.txt directory


Not exactly answering the question...

I'm sure a perl 'solution' is coming soon.

  Réponse avec citation
Vieux 23/05/2007, 15h31   #4
Ron Hardin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: is there a cp argument that preserves directory structure

Kenny McCormack wrote:
>
> In article <s42dnfTHFtJnRc7bnZ2dnUVZ_q2pnZ2d@magma.ca>,
> Jean-Rene David <jrdavid@magma.ca> wrote:
> >* Ben [2007.05.23 05:46]:
> >> e.g. file: ./a/b/c/a.txt
> >> I wanna cp file to a another directory, while mkdir'ing a/b/c/ if
> >> neccessary, can that be done?

> >
> >pax -r -w ./a/b/c/a.txt directory

>
> Not exactly answering the question...
>
> I'm sure a perl 'solution' is coming soon.


echo ./a/b/c/a.txt | cpio -pdm directory

--
Ron Hardin
rhhardin@mindspring.com

On the internet, nobody knows you're a jerk.
  Réponse avec citation
Vieux 23/05/2007, 15h32   #5
Jean-Rene David
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: is there a cp argument that preserves directory structure

* Kenny McCormack [2007.05.23 12:49]:
> In article <s42dnfTHFtJnRc7bnZ2dnUVZ_q2pnZ2d@magma.ca>,
> Jean-Rene David <jrdavid@magma.ca> wrote:
> > * Ben [2007.05.23 05:46]:
> > > e.g. file: ./a/b/c/a.txt
> > > I wanna cp file to a another directory, while mkdir'ing a/b/c/ if
> > > neccessary, can that be done?

> >
> >pax -r -w ./a/b/c/a.txt directory

>
> Not exactly answering the question...


It's portable and does exactly what the OP asked for. In
what way is it not answering the question? Because it
doesn't use cp?

--
JR
  Réponse avec citation
Vieux 23/05/2007, 16h22   #6
Kenny McCormack
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: is there a cp argument that preserves directory structure

In article <nZqdndpZl6DozcnbnZ2dnUVZ_rXinZ2d@magma.ca>,
Jean-Rene David <jrdavid@magma.ca> wrote:
>* Kenny McCormack [2007.05.23 12:49]:
>> In article <s42dnfTHFtJnRc7bnZ2dnUVZ_q2pnZ2d@magma.ca>,
>> Jean-Rene David <jrdavid@magma.ca> wrote:
>> > * Ben [2007.05.23 05:46]:
>> > > e.g. file: ./a/b/c/a.txt
>> > > I wanna cp file to a another directory, while mkdir'ing a/b/c/ if
>> > > neccessary, can that be done?
>> >
>> >pax -r -w ./a/b/c/a.txt directory

>>
>> Not exactly answering the question...

>
>It's portable and does exactly what the OP asked for. In
>what way is it not answering the question? Because it
>doesn't use cp?


Indeed.

What part of 'Is there a *cp* [1] argument that preserves directory structure"
do you not understand?

[1] emphasis mine, Ed.

P.S. Now that someone has provided a cpio 'solution', I'm still holding
out for 'solutions' in perl, Python, and i386 assembler.

  Réponse avec citation
Vieux 23/05/2007, 17h11   #7
Jean-Rene David
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: is there a cp argument that preserves directory structure

* Kenny McCormack [2007.05.23 15:22]:
> What part of 'Is there a *cp* [1] argument that preserves
> directory structure" do you not understand?


I just thought suggesting another tool would be more
productive than the "on-topic" answer, which is "no".

It's certainly more productive than... Well, you know... Ah
never mind.

--
JR [who hadn't used that special keybinding for awhile]
  Réponse avec citation
Vieux 23/05/2007, 19h53   #8
Allodoxaphobia
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: is there a cp argument that preserves directory structure

> Kenny McCormack wrote:

>--
> On the internet, nobody knows you're a jerk.


However, most are suspicious. :-)
  Réponse avec citation
Vieux 23/05/2007, 20h43   #9
Hanspeter 'Happl' Oberlin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: is there a cp argument that preserves directory structure

In article <1179899201.163021.127730@w5g2000hsg.googlegroups. com>,
Ben <chinese.central@googlemail.com> wrote:

>e.g. file: ./a/b/c/a.txt
>I wanna cp file to a another directory, while mkdir'ing a/b/c/ if
>neccessary, can that be done?


man cp

-R If source_file designates a directory, cp copies the directory and
the entire subtree connected at that point. This option also
causes symbolic links to be copied, rather than indirected through,
and for cp to create special files rather than copying them as nor-
mal files. Created directories have the same mode as the corre-
sponding source directory, unmodified by the process' umask.

Note that cp copies hard linked files as separate files. If you
need to preserve hard links, consider using tar(1), cpio(1), or
pax(1) instead.

--
Gruesse aus der Schweiz
Salutations en provenance de Suisse
Saluti dalla Svizzera
Greetings from Switzerland
Happl
  Réponse avec citation
Vieux 24/05/2007, 05h12   #10
Barry Margolin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: is there a cp argument that preserves directory structure

In article <spam4hp-BD5EA5.21435123052007@individual.de>,
Hanspeter 'Happl' Oberlin <spam4hp@gmail.com> wrote:

> In article <1179899201.163021.127730@w5g2000hsg.googlegroups. com>,
> Ben <chinese.central@googlemail.com> wrote:
>
> >e.g. file: ./a/b/c/a.txt
> >I wanna cp file to a another directory, while mkdir'ing a/b/c/ if
> >neccessary, can that be done?

>
> man cp
>
> -R If source_file designates a directory, cp copies the directory and
> the entire subtree connected at that point. This option also
> causes symbolic links to be copied, rather than indirected through,
> and for cp to create special files rather than copying them as nor-
> mal files. Created directories have the same mode as the corre-
> sponding source directory, unmodified by the process' umask.
>
> Note that cp copies hard linked files as separate files. If you
> need to preserve hard links, consider using tar(1), cpio(1), or
> pax(1) instead.


I don't think that's what he's asking for. He doesn't want to copy an
entire directory, he just wants to copy a single file. But that file is
several directories down from his current directory, and he wants to put
it similarly nested in the destination directory.

As others have pointed out, there are tools that can do this. But cp
doesn't have the ability built into it.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h58.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12977 seconds with 18 queries