Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.
Compare 2 files inode modification
Name: gptavares Date: December 19, 2003 at 12:20:51 Pacific OS: UnixWare 7.1.1 CPU/Ram: 320 RAM
Comment:
I need to compare too files in two different directories if the one on DIR1 is newer then the one of DIR2 then I need to move it to DIR2. E.I check if /dir1/file1 is newer the /dir2/file2 if yes then move /dir1/file1 to /dir2/file2 else remove /dir1/file1.
This is what I've tried so far but is not working very well.
if [ /dir1/file1 -nt /dir2/file2] then mv /dir1/file1 /dir2 else rm -f /dir1/file1 fi
Name: Dlonra Date: December 22, 2003 at 05:24:01 Pacific
Reply:
how do you know that file1 and/or file2 exist when you perform the compare?
0
Response Number 2
Name: gptavares Date: December 22, 2003 at 06:31:24 Pacific
Reply:
I realy don't check if file1 or file2 exist, in this case they will always be there. My only concern is that file file1 does not overlay file2 if it's older.
0
Response Number 3
Name: shailesh.bhide Date: December 23, 2003 at 00:48:51 Pacific
Reply:
Do this,
if [ /dir1/file1 -nt /dir2/file2] then mv -f /dir1/file1 /dir2/file2 else rm -f /dir1/file1 fi
Summary: Hi, I have to compare 2 files using shell script. I need to take the each entry/line from the first file and compare it with 2nd file whether that entry exists in second file or not. If found...ok..el...
Summary: Hi, I need to compare two files using shell script. (file1: inbound/data/lockbox & file2:inbound/data/lockbox/archive) If they are same it should email saying files are same and if they are not same...
Summary: Hello Everybody!!!!!!!!! Request you to help me with the below mentioned issue: I have 2 files say, File 1: a|4|7 b|3|2 c|8|8 d|8|9 File 2: a|4|6 b|2|2 c|8|8 d|9|8 The third file(output file) should h...