Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ls question

Status
Not open for further replies.

MoreFeo

Technical User
Nov 29, 2002
547
ES
Hi, we're migrating a server to another HW, and we're copying the data from the old one to the new. We've copied the filesystems (scripts with cpio), and in some of the FS we see BIG differences between used data in the two servers.

I'm trying to see where might be the differences, so I was thinking to make ls -lR > output.txt in each server and then make a diff between the 2 outputs. The problem is that cpio didn't preserve the times of the files, so a diff will show me everything as different.
How could I make so that the times doesn't show in the output file?

Thanks
 
How about something like this:

ls -lR | awk '{print $1" "$2" "$3" "$4" "$5" "$9}' > somefile.txt

that would get you everything except the file time stamp.
 
Good morning,

I know this was not your question - only a hint as for the differences you mentioned ...

Many copy scripts leave out files that begin with a .

Such as .profile / .ssh

and so on ...

As well as symbolic links.
You have to make sure, that the copy script really copies *.*

Last but not least there might be constantly growing log files. These will always be different from the original system.

Regards
Thomas
 
Hi,

You can use cpio with -Md switches :
M Retains previous file modification time even when directories are copied.
u Copies unconditionally. An older file now replaces a newer file with the same name.
 
Another difference can be in the size of directories.

On source server, sometimes a lot of empty dir slots (if you in the past have deleted a lot of files) make up a large dir with only a few files in it.

On the target server, the dir is re-created with small size and just the dir slots needed.

Do
find . -type d -ls
on both servers to look at the differences.


HTH,

p5wizard
 
Thanks all for your tips.

Tsch, thanks for the info, I took a look into our scripts and it does find . ".*" ... and then find . "*" ... I suppose this is what you meant when you said to take care about .files

aau, I looked at man cpio and found the -M option, but we already had our files copied without it, and it was too much data to start again.

p5wizard, you're right (once again), it was a lot of directories that had different sizes. Making diff with the outputs of ls -lR | awk '{print $1" "$5" "9}' we've seen that this was the problem, but with your command it would have been faster.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top