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: signature.asc
Description: OpenPGP digital signature

Reply via email to