[CentOS] Shell Script - Compare packages. rpm.

John Doe jdmls at yahoo.com
Mon Jan 26 12:56:05 UTC 2009

> From: Tiago Dias <tux.tiago at gmail.com>
> I need a script which makes the package compação rpm's through two text files ... 
> Since a file is the output of the command rpm-qa > pkg.out 
> And the second file is a list of several packages rpm's, multiple versions and architectures. 

Just for the fun (and did not really test it):

cat pkg.out 
  awk ' { p=$1; n=match(p, "-[[:digit:]]+"); print substr(p,1,n); } '|
  while read PKG; dogrep "$PKG[0-9]" update.out; done

I will leave you as an exercise to sort the results by versions and head (or tail) to keep the highest one... ^_^
But, if your update.out file contained only the latest package (and not all different versions), that should work.



More information about the CentOS mailing list