Sponsored Content
Top Forums Shell Programming and Scripting Compare two files containing package names and version number Post 302906668 by Chubler_XL on Sunday 22nd of June 2014 07:21:19 PM
Old 06-22-2014
How about this solution, files system_1 and system_2 contain output of rpm -qa like this:

Code:
$ head -3 system_1
gnome-vfs2-smb-2.24.2-6.el6.x86_64
perl-XML-Parser-2.36-7.el6.x86_64
gnome-python2-desktop-2.28.0-5.el6.x86_64

$ head -3 system_2
hplip-libs-3.13.11-4.fc20.x86_64
gnu-free-fonts-common-20120503-8.fc20.noarch
GConf2-3.2.6-7.fc20.x86_64

In the below script specify the following in OPTS:

Code:
A - Package is Additional in file1
M - Package is Missing in file1
N - Version is Newer in file1
O - Version is Older in file1
S - Version is the Same in file1 and file2
D - Debug print version numbers with package names

And here is your code (options used here are Debug plus Newer and Additional in file1):

Code:
awk -v OPT=DNA '
FNR==1{sys++}
{
   match($0,"-[0-9]")
   pkg=substr($0,1,RSTART-1)
   ver=substr($0,RSTART+1)
   if (sys==1) {
      PKGS[pkg]=ver
      next
   }
   if(!(pkg in PKGS)) {
      if(index(OPT, "M")) print "M:" pkg (index(OPT, "D") ? "(" ver ")":"")
      next
   }
   if (index(OPT, "D")) debug="(" PKGS[pkg] " vrs " ver ")"
   if (index(OPT, "N") && PKGS[pkg] > ver) print "N:" pkg debug
   if (index(OPT, "O") && PKGS[pkg] < ver) print "O:" pkg debug
   if (index(OPT, "S") && PKGS[pkg] == ver) print "S:" pkg debug
   delete PKGS[pkg]
}
END {
   if (index(OPT, "A")) for(pkg in PKGS) print "A:" pkg (index(OPT, "D") ? "(" PKGS[pkg] ")":"")
}' system_1 system_2

Output is <Type>:<package> , where <Type> is single letter from "NOMAS" and <package> is package name plus optional debug info.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

total number of files which have "aaa" in files whose names are File*_bbb*

I am getting the list of all the files which have "aaa" from files whose name is File*_bbb*. grep -l "aaa" File*_bbb* But I want to count the number of files. That is I want the total number of files which have "aaa" in files File*_bbb* If I run the following for getting number of... (1 Reply)
Discussion started by: sudheshnaiyer
1 Replies

2. Shell Programming and Scripting

Finding files with names that have a real number greater then difined.

I am trying to find all files in a directory whose name has a real number larger then the number I am looking for. For example: . |-- delta.1.5.sql |-- delta.2.1.sql |-- delta.2.2.sql |-- delta.2.3.sql |-- delta.2.4.sql `-- delta.2.5.sql I know my database is at 2.2 so I want an... (2 Replies)
Discussion started by: harmonwood
2 Replies

3. Shell Programming and Scripting

Script to Compare a large number of files.

I have a large Filesystem on an AIX server and another one on a Red Hat box. I have syncd the two filesystems using rsysnc. What Im looking for is a script that would compare to the two filesystems to make sure the bits match up and the number of files match up. its around 2.8 million... (5 Replies)
Discussion started by: zippdawg2001
5 Replies

4. UNIX for Dummies Questions & Answers

Substract a certain number to the names of several files

We have a list of files (raw and jpeg types) with 2 different extensions (rw2 and jpg). When there is both the raw and jpeg files, their file numbers must be the same (215 and 215, 218 and 218). Sometimes there is only the jpeg file (216,217). bla_215.rw2 bla_215.jpg bla_216.jpg bla_217.jpg... (9 Replies)
Discussion started by: Epictete
9 Replies

5. Shell Programming and Scripting

Compare list [ names and size files ]

Hello, I've downloaded a huge amont of files I've got a list of files from a remote server. -rw-r--r-- 1 str661 strem 453465260 Dec 16 15:54 SATRYS2V1_20021218_temp_bias.nc -rw-r--r-- 1 str661 strem 17669468 Dec 16 18:01 SATRYS2V1_20021225_hdyn_bias.nc -rw-r--r-- 1... (9 Replies)
Discussion started by: Aswex
9 Replies

6. UNIX for Dummies Questions & Answers

how to compare names of files?

hi, can somebody tell me how to compare names of files? the situation is I have 2 files file1 and file2 and I want to figure out which file has the biggest ending, in this case file2 is. thank you (3 Replies)
Discussion started by: s3270226
3 Replies

7. Shell Programming and Scripting

Check for particular files and compare the file names

Hi, Below are the 2 files in directory /tmp: masterCSF242323.img indexCSF242323.img 1) I want to compare if both the number (242323) are same in both the files. If they are same print - Files matching, else print files do not match. 2) Also if only index file is present in that... (7 Replies)
Discussion started by: apatil65
7 Replies

8. Shell Programming and Scripting

Compare two files, then outputs line number

I have two files, "ranked.txt" and "sorted.txt". Sorted.txt is a smaller subset from ranked.txt that is sorted in alpha order. However ranked.txt preserves the ranking of words I would like to keep. How do I check the rank of every word in sorted.txt when matched to the original ranked.txt? I... (8 Replies)
Discussion started by: pxalpine
8 Replies

9. Shell Programming and Scripting

Compare two files and get only missing names

I need to compare two files (oldfile1 & newfile). Need to ignore the values which are present in both files. At the same time, i need to get only records in new file. Tried using Join -v1 -v2 oldfile1 newfile (suspect it has not worked as expected). could anyone of you please help me here. (5 Replies)
Discussion started by: Selva_2507
5 Replies

10. Shell Programming and Scripting

Compare files with different names in different directories

Hi, I have a requirement to compare files in different directories with different names. The files have a datestamp in their name (It might not be a sequential datetimestamp). This is for Redhat Linux. I have more than 5 directories and more than 10 file in each directory to be compared. ... (4 Replies)
Discussion started by: GosarJunk
4 Replies
DEBDIFF(1)						      General Commands Manual							DEBDIFF(1)

NAME
debdiff - compare file lists in two Debian packages SYNOPSIS
debdiff [options] debdiff [options] ... deb1 deb2 debdiff [options] ... changes1 changes2 debdiff [options] ... --from deb1a deb1b ... --to deb2a deb2b ... debdiff [options] ... dsc1 dsc2 DESCRIPTION
debdiff takes the names of two Debian package files (.debs or .udebs) on the command line and compares their contents (considering only the files in the main package, not the maintenance scripts). It shows which files have been introduced and which removed between the two pack- age files, and is therefore useful for spotting files which may have been inadvertently lost between revisions of the package. It also checks the file owners and permissions, and compares the control files of the two packages using the wdiff program. If no arguments are given, debdiff tries to compare the content of the current source directory with the last version of the package. debdiff can also handle changes between groups of .deb files in two ways. The first is to specify two .changes files. In this case, the .deb files listed in the .changes file will be compared, by taking the contents of all of the listed .deb files together. (The .deb files listed are assumed to be in the same directory as the .changes file.) The second way is to list the .deb files of interest specifically using the --from ... --to syntax. These both help if a package is broken up into smaller packages and one wishes to ensure that nothing is lost in the interim. debdiff examines the devscripts configuration files as described below. Command line options override the configuration file settings, though. If debdiff is passed two source packages (.dsc files) it will compare the contents of the source packages. If the source packages differ only in Debian revision number (that is, the .orig.tar.gz files are the same in the two .dsc files), then interdiff(1) will be used to com- pare the two patch files if this program is available on the system, otherwise a diff will be performed between the two source trees. OPTIONS
--dirs, -d The default mode of operation is to ignore directory names which appear in the file list, but they, too, will be considered if this option is given. --nodirs Ignore directory names which appear in the file list. This is the default and it can be used to override a configuration file set- ting. --move FROM TO, -m FROM TO It sometimes occurs that various files or directories are moved around between revisions. This can be handled using this option. There are two arguments, the first giving the location of the directory or file in the first package, and the second in the second. Any files in the first listing whose names begin with the first argument are treated as having that substituted for the second argu- ment when the file lists are compared. Any number of --move arguments may be given; they are processed in the order in which they appear. --move-regex FROM TO This is the same as --move, except that FROM is treated as a regular expression and the perl substitution command s/^FROM/TO/ is applied to the files. In particular, TO can make use of backreferences such as $1. --nocontrol debdiff will usually compare the respective control files of the packages using wdiff(1). This option suppresses this part of the processing. --control Compare the respective control files; this is the default, and it can be used to override a configuration file setting. --controlfiles FILE[,FILE ...] Specify which control files to compare; by default this is just control, but could include postinst, config and so on. Files will only be compared if they are present in both .debs being compared. The special value ALL compares all control files present in both packages, except for md5sums. This option can be used to override a configuration file setting. --wdiff-source-control When processing source packages, compare control files using wdiff. Equivalent to the --control option for binary packages. --no-wdiff-source-control Do not compare control files in source packages using wdfiff. This is the default. --wp, --wl, --wt Pass a -p, -l or -t option to wdiff respectively. (This yields the whole wdiff output rather than just the lines with any changes.) --show-moved If multiple .deb files are specified on the command line, either using .changes files or the --from/--to syntax, then this option will also show which files (if any) have moved between packages. (The package names are simply determined from the names of the .deb files.) --noshow-moved The default behaviour; can be used to override a configuration file setting. --renamed FROM TO If --show-moved is being used and a package has been renamed in the process, this command instructs debdiff to treat the package in the first list called FROM as if it were called TO. Multiple uses of this option are permitted. --exclude PATTERN Exclude files that match PATTERN. Multiple uses of this option are permitted. --diffstat Include the result of diffstat before the generated diff. --no-diffstat The default behaviour; can be used to override a configuration file setting. --auto-ver-sort When comparing source packages, do so in version order. --no-auto-ver-sort Compare source packages in the order they were passed on the command-line, even if that means comparing a package with a higher ver- sion against one with a lower version. This is the default behaviour. --unpack-tarballs When comparing source packages, also unpack tarballs found in the top level source directory to compare their contents along with the other files. This is the default behaviour. --no-unpack-tarballs Do not unpack tarballs inside source packages. --no-conf, --noconf Do not read any configuration files. This can only be used as the first option given on the command-line. --help, -h Show a summary of options. --version, -v Show version and copyright information. --quiet, -q Be quiet if no differences were found. --ignore-space, -w Ignore whitespace in diffs. CONFIGURATION VARIABLES
The two configuration files /etc/devscripts.conf and ~/.devscripts are sourced by a shell in that order to set configuration variables. Command line options can be used to override configuration file settings. Environment variable settings are ignored for this purpose. The currently recognised variables are: DEBDIFF_DIRS If this is set to yes, then it is the same as the --dirs command line parameter being used. DEBDIFF_CONTROL If this is set to no, then it is the same as the --nocontrol command line parameter being used. The default is yes. DEBDIFF_CONTROLFILES Which control files to compare, corresponding to the --controlfiles command line option. The default is control. DEBDIFF_SHOW_MOVED If this is set to yes, then it is the same as the --show-moved command line parameter being used. DEBDIFF_WDIFF_OPT This option will be passed to wdiff; it should be one of -p, -l or -t. DEBDIFF_SHOW_DIFFSTAT If this is set to yes, then it is the same as the --diffstat command line parameter being used. DEBDIFF_WDIFF_SOURCE_CONTROL If this is set to yes, then it is the same as the --wdiff-source-control command line parameter being used. DEBDIFF_AUTO_VER_SORT If this is set to yes, then it is the same as the --auto-ver-sort command line parameter being used. DEBDIFF_UNPACK_TARBALLS If this is set to no, then it is the same as the --no-unpack-tarballs command line parameter being used. EXIT VALUES
Normally the exit value will be 0 if no differences are reported and 1 if any are reported. If there is some fatal error, the exit code will be 255. SEE ALSO
dpkg-deb(1), wdiff(1), interdiff(1), diffstat(1) and devscripts.conf(5). AUTHOR
debdiff was originally written as a shell script by Yann Dirson <dirson@debian.org> and rewritten in Perl with many more features by Julian Gilbey <jdg@debian.org>. The software may be freely redistributed under the terms and conditions of the GNU General Public License, ver- sion 2. DEBIAN
Debian Utilities DEBDIFF(1)
All times are GMT -4. The time now is 10:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy