|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
* 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 |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
* 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 |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
* 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] |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
> Kenny McCormack wrote:
>-- > On the internet, nobody knows you're a jerk. However, most are suspicious. :-) |
|
|
|
#9 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#10 |
|
Messages: n/a
Hébergeur: |
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 *** |
|
![]() |
| Outils de la discussion | |
|
|