Operating System - HP-UX
1834862 Members
2787 Online
110070 Solutions
New Discussion

command to list all directories and files inside it including sizes

 
SOLVED
Go to solution
JRiggs
Occasional Contributor

command to list all directories and files inside it including sizes

Hi,

Hope some guro could help me with my problem.
I need the list for control total checking
when we migration to another storage..

I'll be comparing the list againts the directories and files after I have restored my backup to the new storage..

thanks in advance.

Jasper
The choices you get are the choices you make
9 REPLIES 9
Tommy Brown
Respected Contributor

Re: command to list all directories and files inside it including sizes

I used to use: "ls -lR"
it is quite long, but shows all subdirectories and files..
Tommy
I may be slow, but I get there !
Joseph C. Denman
Honored Contributor

Re: command to list all directories and files inside it including sizes

ls -alR ./*

...jcd...
If I had only read the instructions first??
Vincenzo Restuccia
Honored Contributor
Solution

Re: command to list all directories and files inside it including sizes

#ll -R
Tracey
Trusted Contributor

Re: command to list all directories and files inside it including sizes

If you want it in blocks, try du -s
Deepak_5
Advisor

Re: command to list all directories and files inside it including sizes

du -a ./
would gives each entry filewise in the current and
sub directory

JRiggs
Occasional Contributor

Re: command to list all directories and files inside it including sizes

Hi,

Thanks, but how am I going to compare these with my restored data...

Any command or script that you recommend to ensure that my checking is 100% reliable...

please advise.

thanks.

The choices you get are the choices you make
Gregory Fruth
Esteemed Contributor

Re: command to list all directories and files inside it including sizes

To verify that two files are EXACTLY the same, use
cksum. Just checking the size isn't good enough.
Use find to run cksum on all files in dir1 and dir2:

cd dir1; find . -type f -exec cksum {} \; | sort -k3 > /tmp/log1
cd dir2; find . -type f -exec cksum {} \; | sort -k3 > /tmp/log2

Then use diff, sdiff,cmp, etc. to compare log1 and log2.

HTH
Joseph C. Denman
Honored Contributor

Re: command to list all directories and files inside it including sizes

If 100% verification if needed, I agree with gregory. However, I would probably do the ls -alR > /tmp/oldhost.txt on the old host, and then ls -alR > /tmp/newhost.txt on the new host. ftp the oldhost.txt to the new host. Then do a diff on the files. There should be no discrepencies. The I would do a random spot check on some of the important files.

...jcd...
If I had only read the instructions first??
James R. Ferguson
Acclaimed Contributor

Re: command to list all directories and files inside it including sizes

Hi Jasper:

Gregory's approach is the correct one.

First, trying to compare the size of directories (from 'ls' or 'du') is futile. Blocks once allocated to a directory for file inodes are not deallocated when the file is removed. Thus, it is very common for a directory's size to shrink if it is recreated and its files reloaded.

When "sparse" files are copied, the space they occupy is null-filled. Comparing the original file with its copy with 'ls' will show different sizes. In fact, this is one way to detect the presence of a sparse file. Comparing the checksums of the two files will yield the same values, regardless of "sparseness".

A very good discussion of sparse files can be found in a recent post in the comments by Bill Hassell:

http://forums.itrc.hp.com/cm/QuestionAnswer/1,1150,0xcfdcf9beca68d511abcd0090277a778c,00.html

...JRF...