1 |
Am 29.01.2011 14:58, schrieb Alex Schuster: |
2 |
> Hi there! |
3 |
> |
4 |
> I am currently putting extra backups to old hard drives I do no longer need |
5 |
> for other purposes. After that I send the putput out ls -lR and du -m to my |
6 |
> log directory so I can check what files are on which drive without having to |
7 |
> attach the drive. |
8 |
> |
9 |
> Works, though a better method would be to clone the drive's root directory, |
10 |
> but with all file sizes being zero. This way I can easily navigate the |
11 |
> directory structure, instead of browsing through the ls-lR file. Is there a |
12 |
> utility that does this? It would be even better if the files would be |
13 |
> created as sparse files, faking the original size. |
14 |
> |
15 |
> I just wrote a little script that does this, but it does not do the sparse |
16 |
> file thing yet, and would have problems with newline in file names. And I |
17 |
> guess someone already wrote such a utility? |
18 |
> |
19 |
> Wonko |
20 |
> |
21 |
|
22 |
Use `truncate -s <size> <file>` |
23 |
|
24 |
It creates a sparse file if the specified file is smaller than the |
25 |
specified size. It will also create a new file if it does not yet exist. |
26 |
|
27 |
In order to avoid trouble with line breaks in names, I recommend |
28 |
something like: |
29 |
find . -type f -print0 | |
30 |
while read -d $'\0' file; do |
31 |
echo "File=$file" |
32 |
done |
33 |
|
34 |
Or use similar commands accepting or outputting 0-byte terminated |
35 |
strings, for example xargs -0, du -0, grep -z. |
36 |
|
37 |
For copying file attributes from one file to another you can use `cp |
38 |
--attributes-only`. |
39 |
|
40 |
Hope this helps, |
41 |
Florian Philipp |