The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 11-18-2007
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,915

Code:
awk 'NR==FNR{x[$NF];next}
{print ($1 in x)?$1:"error: entry "$1" has no entry in file2"
}' FS="/" file2 file1


Use nawk or /usr/xpg4/bin/awk on Solaris.


PS. Just saw the post above,
if you wnat an output like that:


Code:
awk 'NR==FNR{x[$NF];next}
!($1 in x)&&$0="error: entry "$1" has no entry in file2"
' FS="/" file2 file1


Last edited by radoulov; 11-18-2007 at 12:43 PM..