![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| FTP Return Code | wilsonSurya | UNIX for Dummies Questions & Answers | 1 | 10-06-2008 08:27 AM |
| to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 's | manas6 | UNIX for Dummies Questions & Answers | 0 | 06-05-2008 07:44 AM |
| asking about return code | naamas03 | Shell Programming and Scripting | 3 | 08-28-2007 05:53 AM |
| return code of a process | filedeliver | High Level Programming | 1 | 04-19-2007 02:42 AM |
| Return Code of tar in AIX | dupeng | AIX | 3 | 02-23-2004 12:05 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
CMP two files with slight difference and return code
I am comparing two files which are identical except for the timestamp which is incorporated within the otherwise same 372 bytes. I am using the command:
cmp -s $Todays_file $Yesterdays_file -i 372 When I run the command without the -i 372 it shows the difference i.e. the timestamp. However, with -i 372 it works as expected displays no differences as it ignores the first 372 bytes. However, in both cases the return code is set to 1. I was hoping that in the second case the return code would be set to 0 i.e. no changes as we are ignoring the first 372 bytes. I do some further processing based on the return code. Is there a way I can compare the two files? |
|
|||||
|
Hi. The GNU cmp seems to work for me: Code:
#!/bin/bash - # @(#) s1 Demonstrate cmp, skipping initial bytes. echo echo "(Versions displayed with local utility \"version\")" version >/dev/null 2>&1 && version "=o" $(_eat $0 $1) cmp set -o nounset echo FILE1=data1 FILE2=data2 echo " Data file $FILE1:" cat $FILE1 echo echo " Data file $FILE2:" cat $FILE2 echo echo " Results for comparison of entire files:" cmp $FILE1 $FILE2 echo " Exit code is $?" echo echo " Results for comparison of files past byte 5:" cmp -i 5 $FILE1 $FILE2 echo " Exit code is $?" echo echo " Results for comparison options in non-standard order:" cmp $FILE1 $FILE2 -i 5 echo " Exit code is $?" exit 0 Producing: Code:
% ./s1 (Versions displayed with local utility "version") Linux 2.6.11-x1 GNU bash 2.05b.0 cmp (GNU diffutils) 2.8.1 Data file data1: junk1 in this line. hello, world. Data file data2: junk2 in this line. hello, world. Results for comparison of entire files: data1 data2 differ: char 5, line 1 Exit code is 1 Results for comparison of files past byte 5: Exit code is 0 Results for comparison options in non-standard order: Exit code is 0 Are you taking into account that the exit code is reset for each command? ... cheers, drl |
|
|||||
|
Hi, otheus.
Quote:
Does the utility accept the the "-i" option? ... cheers, drl |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|