Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Help in grep function or similar using awk

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 10-20-2009
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

dfghd
dfghe
dfgey
dfgeu

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

for ex. file2
>dfghd
gfdgfddl;klfkld;ld;lgl;dld'l'dv
>dfghe
gkwhjhsgdjdjdjhjddj
>dfgey
jdkjfhdjhfdkjhfdkhkdk

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
    #2  
Old Unix and Linux 10-20-2009
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 28 September 2016, 4:26 PM EDT
Location: Amsterdam
Posts: 11,014
Thanks: 431
Thanked 3,061 Times in 2,714 Posts

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

Sponsored Links
Closed

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 07:19 AM
Similar OS to AIX agasamapetilon AIX 5 12-01-2008 12:16 PM
Passing global variable to a function which is called by another function sars Shell Programming and Scripting 4 06-30-2008 11:39 AM
how to get the similar function in while loop or for loop trynew Shell Programming and Scripting 3 06-17-2002 11:09 AM



All times are GMT -4. The time now is 06:10 AM.