From: Florian Philipp <lists@binarywings.net>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] Cloning a directory hierarchy, but not the content
Date: Sat, 29 Jan 2011 15:39:32 +0100 [thread overview]
Message-ID: <4D4426A4.9060303@binarywings.net> (raw)
In-Reply-To: <201101291458.13533.wonko@wonkology.org>
[-- Attachment #1: Type: text/plain, Size: 1514 bytes --]
Am 29.01.2011 14:58, schrieb Alex Schuster:
> Hi there!
>
> I am currently putting extra backups to old hard drives I do no longer need
> for other purposes. After that I send the putput out ls -lR and du -m to my
> log directory so I can check what files are on which drive without having to
> attach the drive.
>
> Works, though a better method would be to clone the drive's root directory,
> but with all file sizes being zero. This way I can easily navigate the
> directory structure, instead of browsing through the ls-lR file. Is there a
> utility that does this? It would be even better if the files would be
> created as sparse files, faking the original size.
>
> I just wrote a little script that does this, but it does not do the sparse
> file thing yet, and would have problems with newline in file names. And I
> guess someone already wrote such a utility?
>
> Wonko
>
Use `truncate -s <size> <file>`
It creates a sparse file if the specified file is smaller than the
specified size. It will also create a new file if it does not yet exist.
In order to avoid trouble with line breaks in names, I recommend
something like:
find . -type f -print0 |
while read -d $'\0' file; do
echo "File=$file"
done
Or use similar commands accepting or outputting 0-byte terminated
strings, for example xargs -0, du -0, grep -z.
For copying file attributes from one file to another you can use `cp
--attributes-only`.
Hope this helps,
Florian Philipp
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
next prev parent reply other threads:[~2011-01-29 14:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-29 13:58 [gentoo-user] Cloning a directory hierarchy, but not the content Alex Schuster
2011-01-29 13:54 ` Etaoin Shrdlu
2011-01-29 14:27 ` Alex Schuster
2011-01-29 14:36 ` Etaoin Shrdlu
2011-01-29 16:45 ` Alex Schuster
2011-01-29 18:59 ` Etaoin Shrdlu
2011-01-29 23:51 ` Alex Schuster
2011-01-29 14:39 ` Florian Philipp [this message]
2011-01-29 19:31 ` Alex Schuster
2011-01-29 21:14 ` Florian Philipp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D4426A4.9060303@binarywings.net \
--to=lists@binarywings.net \
--cc=gentoo-user@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox