Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Mar 2005 23:39:02 +0200
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        Joachim Dagerot <jd@dagerot.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Moving a directory hierarchy - best practice?
Message-ID:  <20050304213902.GA1276@gothmog.gr>
In-Reply-To: <200503042113.j24LD51s026558@mail-core.space2u.com>
References:  <200503042113.j24LD51s026558@mail-core.space2u.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2005-03-04 22:13, Joachim Dagerot <jd@dagerot.com> wrote:
>
> Thanks for your suggestion.

You're welcome, but *please* do not post replies _before_ the text to
which you reply.  It's extremely annoying to read the reply then.

>>> The best suggestion was from
>>> http://badgertronics.com/knowledge/one.adp?parent=25:
>>>
>>> To move /tmp/blarg to /var:
>>> % cd /tmp
>>> % tar cvf - blarg | (cd /var; tar xf -)
>>> [...]
>>> How do you guys move around your directory structures from prompt?
>>
>>I have used the following many times, with very good results:
>>
>>	# cd /source/path
>>	# find . | cpio -p -dmvu /destination/dir
>
> Unfortunately your commands will not affect the root folder of the
> hierarchy.

I'm not sure I understand what you mean by "affect the root folder".

> I must create a directory in the destination path with the same name
> of the folder where my data is in. example:
>
> /home/user/level1/l2/l3/l4
>
> I would like to move level1 to a new location:
>
> mvdir /home/user/level1 /root/
>
> That would be awsome!

You can do the moving in two steps:

	1. Copy the directory level1 to /root/level1
	2. Delete the original.

These steps can easily be done with:

1.	# cd /home/user/level1
	# find . | cpio -p -dmvu /root/level1

2.	# cd /home/user
	# rm -fr level1

The -dmu options to cpio are important.
See the cpio manpage for details.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050304213902.GA1276>