Unix/Linux Go Back    

Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Help in grep function or similar using awk

Shell Programming and Scripting

Thread Tools Search this Thread Display Modes
Old Unix and Linux 10-20-2009   -   Original Discussion by Lucky Ali
Lucky Ali Lucky Ali is offline
Registered User
Join Date: Oct 2009
Last Activity: 31 January 2014, 7:06 PM EST
Posts: 175
Thanks: 18
Thanked 0 Times in 0 Posts
Help in grep function or similar using awk

I have a list of id;

for example: file 1


I have another data file that contain this ids as headers;

for ex. file2

I wanted to compare file 1 and file 2 such a way that the output list the ids that are present in file 1 but not present in file 2.
For ex. the id 'dfgeu' is present in file 1 but its absent in file 2.

I want to have this id (dfgeu)which is missing in file 2 as header to be outputed.

Is there a way in awk to do this comparison of 2 files?

Please let me know.
Sponsored Links
Old Unix and Linux 10-20-2009   -   Original Discussion by Lucky Ali
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Join Date: Nov 2008
Last Activity: 19 November 2017, 11:16 PM EST
Location: Amsterdam
Posts: 11,620
Thanks: 517
Thanked 3,380 Times in 2,979 Posts

awk 'NR==FNR {A[$1]=1; getline; next} !A[">"$1]' file2 file1

Sponsored Links

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
what is the similar command for "grep -v" in nawk? prsam UNIX for Dummies Questions & Answers 7 12-08-2008 08:19 AM
Similar OS to AIX agasamapetilon AIX 5 12-01-2008 01:16 PM
Passing global variable to a function which is called by another function sars Shell Programming and Scripting 4 06-30-2008 12:39 PM
how to get the similar function in while loop or for loop trynew Shell Programming and Scripting 3 06-17-2002 12:09 PM

All times are GMT -4. The time now is 05:36 AM.