du -s -k differences between two identical directories


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers du -s -k differences between two identical directories
# 1  
Old 08-06-2007
du -s -k differences between two identical directories

I tarred a directory from a linux server to a solaris server. When I do a du -s -k on the directory, I get almost 150k difference in the file sizes. If I do a ls | wc -l, it is the same. If I look at the size of the individual files, it is the same.

I did an ls on the 2 directories and notice when a directory is within a directories I checking, it can show as 4096 on the linux side and 512 on the Solaris side. Will this alter my results? I do not see any missing files or file size differences. The only difference is the directory size.

I need to make sure these are identical directories?

Any ideas or recommendations?

Thanks
# 2  
Old 08-06-2007
The size of the directory will make a difference. If you have to confirm that you have copied all the files, just run a "find . -type f" command on the directory on source and then on dest. Compare the two outputs. If they are the same, you don't have any problems. To really confirm that the files are copied across correctly, you can use cksum/md5sum on individual files and then compare the results.
# 3  
Old 08-06-2007
Thank you.

I believe all the files are there and the file sizes are the same. I am wondering is why the du -s -k reports different sizes. What is the difference in the directory size (ie) one is 4096 on solaris and it is 512 on linux.

What parameters can I pass the du that they use the same, block size maybe, so the totals come out the same (if in fact they are the same).

Thanks
# 4  
Old 08-06-2007
It hasn't just to do with the block size. With a directory, as files are added, the size increases, but it doesn't reduce when files are removed. So a directory that had more files in it in the past will be larger than it should be.

If you take a tar of that directory and untar it on some other system/to some other location, the new directory that will be created will not (necessarily) the same size as the source directory. It will be only big enough to hold the current file list.
# 5  
Old 08-06-2007
The block sizes are important. When you write a one byte file, you do not simply consume a single byte. The file system code must allocate the smallest unit of space that it can. This varies from filesytem to filesystem. If the smallest unit is 1024 bytes, that is what du reports. After all, when you delete the one byte file, 1024 bytes will be freed. Now copy the that one byte file to another filesystem where 8192 bytes is the smallest unit that can be allocated and du now reports that.
# 6  
Old 08-07-2007
Quote:
Originally Posted by Perderabo
The block sizes are important.
I agree. And I never said they weren't. I meant that apart from the block sizes, this is another possibility.
# 7  
Old 08-07-2007
Thank you very much. Every answer was helpful.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare directories and copy differences (files) in a another directory

Hey im working on script that can compare 2 directory and check difference, then copy difference files in third diretory. here is the story: in folder one we have 12 subfolder and in each of them near 500 images hosted. 01 02 03 04 05 06 07 08 09 10 11 12 in folder 2 we have same subfolder... (2 Replies)
Discussion started by: nimafire
2 Replies

2. Shell Programming and Scripting

Chksum on two directories then copy if they are not identical or existing

How can I have an intelligent script that will copy from source to destination directory if the file doesnt exist there or the chksum is not match. SOURCE directory: for i in `ls` > do > echo $i > md5sum $i > echo "" > done asdasda 00039a616135792fb609d04cf27aed95 asdasda ... (5 Replies)
Discussion started by: kenshinhimura
5 Replies

3. UNIX Desktop Questions & Answers

Help for applying same actions to different directories with identical sub-directories

Hello all I have a situation and would be grateful if you will help me... I am not sure whether it is even possible I have few folders/directories ---e.g. A - B - C -in my MAIN directory for each of them I would get the data from folder called DATA and go through a long list of actions which... (5 Replies)
Discussion started by: A-V
5 Replies

4. Ubuntu

reinstall identical system?

I have my Ubuntu system nicely tailored to my needs, with specific software installed, and other things removed. I'd like to build a new PC, and have the identical software configuration on it. Is there some easy way to export the list of installed software to a file? Then have the new machine... (3 Replies)
Discussion started by: lupin..the..3rd
3 Replies

5. UNIX for Dummies Questions & Answers

more than 10 identical lines

I have a file that looks like this 10 user1s, 5 user2s and 10 users3. 10.10.1.1 user1 10.10.1.1 user1 10.10.1.1 user1 10.10.1.1 user1 10.10.1.1 user1 10.10.1.1 user1 10.10.1.1 user1 10.10.1.1 user1 10.10.1.1 user1 10.10.1.1 user1 10.10.1.2 user2 10.10.1.2 user2 10.10.1.2 user2... (7 Replies)
Discussion started by: lawsongeek
7 Replies

6. Shell Programming and Scripting

Differences between 2 directories

Hi, I am trying to write a script under ksh to list all the differences between two directories. For example: # ls test1 test2 I need to compare all the files under between test1 & test2. When I do diff, it only compares the diectoires but it doesn't check inside. I did do... (3 Replies)
Discussion started by: samnyc
3 Replies

7. Shell Programming and Scripting

Differences between 2 Flat Files and process the differences

Hi Hope you are having a great weeknd !! I had a question and need your expertise for this : I have 2 files File1 & File2(of same structure) which I need to compare on some columns. I need to find the values which are there in File2 but not in File 1 and put the Differences in another file... (5 Replies)
Discussion started by: newbie_8398
5 Replies

8. Shell Programming and Scripting

Compare File Differences in different directories

Hello, I am new to scripting and have been trying to compare two different directories, but with all the same file names in each directory for file changes. I have been doing it in baby steps and have been doing pretty good, but I have hit a few snags. Test 1 and Test 2 work great, but my... (4 Replies)
Discussion started by: dmaday
4 Replies

9. Shell Programming and Scripting

to get two almost identical rows into one

Hi All, I am having hard time in getting two almost identical rows into one, I know how to do if starting word is unique, anyhow this is my problem Input File: issue1 5167 dum 1 1 kkk 7888 dum 2 1 ffff 7888 dum 2 2 llll 7888 dum 3 1 eee 7888 issue2 7667 dum 2 1 jjjj 8999 dum 2 2 jjjj... (3 Replies)
Discussion started by: ricky315
3 Replies

10. UNIX for Dummies Questions & Answers

How to check the files are Identical or not?

Hi, I am taking backup in every hr and every day, I want to programmatically check my backup files are identical with original files. Any methods are available in Unix scripts? Any idea.? I don't want to download both and compare, I looking for idea to develop a script to read both files and... (3 Replies)
Discussion started by: redlotus72
3 Replies
Login or Register to Ask a Question