Sponsored Content
Top Forums Shell Programming and Scripting Compare strings between 2 arrays and print number in AWK Post 302567073 by ahamed101 on Saturday 22nd of October 2011 06:11:10 AM
Old 10-22-2011
Try this...

Code:
awk 'BEGIN{
    a[1]="4|Mike F"
    a[2]="7|John M"
    a[3]="3|Carl L"
    a[4]="8|Mike F"
    a[5]="5|John M"
    a[6]="9|Carl L"
    b[1]="Carl L"
    b[2]="John M"
    b[3]="Mike F"
}
{
  for(j in b){
    for(i=1;i<=length(a);i++){
      if(b[j] ~ a[i]){
        split(a[i],arr,"|")
        print arr[1]
      }
    }
  }
}'

--ahamed
This User Gave Thanks to ahamed101 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to print only lines in between two strings using awk

Hi, I want to print only lines in between two strings and not the strings using awk. Eg: OUTPUT top 2 bottom 1 left 0 right 0 page 66 END I want to print into a new file only top 2 bottom 1 left 0... (4 Replies)
Discussion started by: jisha
4 Replies

2. Shell Programming and Scripting

Compare two strings, and print lines containing mismatches

pls help me on this... and im really sorry because i really don't know where to start here... FILE1 ABC DEF 10 2 DEF GHI 11 3 GHI JKL 12 5 JKL MNO 13 7 MNO PQR 14 5 requirements: 1. The third string should only be 10 or 12 2. The fourth string should only be 2 or 3 3. Prinnt... (1 Reply)
Discussion started by: kingpeejay
1 Replies

3. UNIX for Dummies Questions & Answers

Print number of occurrences of many different strings

People, I need your help with making a script which will 1. take as an input the number of lines, smth like this: ((RUBROBACTER_1_PE1288 (((SALINISPORA_1_PE1863 SALINISPORA_1_PE1828)100 ((NOCARDIOIDES_2_PE2419 PROPIONIBACTERIUM_1_PE1395)96 ((((((((CORYNEBACTERIUM_1_PE1119... (3 Replies)
Discussion started by: roussine
3 Replies

4. Shell Programming and Scripting

awk arrays - compare value in second column to variable

Hello, I am trying to redirect files to a directory by using a config file. The config files is as such: xxxxxx,ID,PathToDirectory xxxxxx,ID2,PathToDirectory2 and so on... I have a variable that should match one of these IDs. I want to load this config file into an awk array, and... (2 Replies)
Discussion started by: jrfiol
2 Replies

5. Shell Programming and Scripting

AWK print number of records, divide this number

I would like to print the number of records of 2 files, and divide the two numbers awk '{print NR}' file1 > output1 awk '{print NR}' file2 > output2 paste output1 output2 > output awl '{print $1/$2}' output > output_2 is there a faster way? (8 Replies)
Discussion started by: programmerc
8 Replies

6. UNIX for Dummies Questions & Answers

awk: don't print sub-arrays

Hi ! I have this input: 12{11}{11110}{80}3456 {123}15{60}9876{8083}34 I try to work on individual numbers between braces. 3 possible cases (here I used colours to be clearer only): - there is no "0" among the characters between braces: so we don't touch anything. - there is a "0" among... (4 Replies)
Discussion started by: beca123456
4 Replies

7. Shell Programming and Scripting

Problem facing to compare different column and print out record with smallest number

Hi, Input file 1 : 37170 37196 77 51 37174 37195 73 52 37174 37194 73 53 Desired Output file 1 : 37170 37196 77 51 Input file 2 : 37174 37195 73 0 37170 37196 77 0 Desired Output file 2 : 37174 37195 73 0 (1 Reply)
Discussion started by: cpp_beginner
1 Replies

8. Shell Programming and Scripting

awk to find number in a field then print the line and the number

Hi I want to use awk to match where field 3 contains a number within string - then print the line and just the number as a new field. The source file is pipe delimited and looks something like 1|net|ABC Letr1|1530||| 1|net|EXP_1040 ABC|1121||| 1|net|EXP_TG1224|1122||| 1|net|R_North|1123|||... (5 Replies)
Discussion started by: Mudshark
5 Replies

9. Shell Programming and Scripting

Compare multiple arrays elements using awk

I need your help to discover missing elements for each box. In theory each box should have 4 items: ITEM01, ITEM02, ITEM08, and ITEM10. Some boxes either have a missing item (BOX02 ITEM08) or might have da duplicate item (BOX03 ITEM02) and missing another one (BOX03 ITEM01). file01.txt ... (2 Replies)
Discussion started by: alex2005
2 Replies

10. UNIX for Beginners Questions & Answers

awk sum of 2 arrays and compare

i'm new to awk, and i've been searching on the forum for sum of a column but all the scripts does sum a column of an entire file. I've a file like this: cat file.txt 1234 5678 5678 1234 I want to use awk to do sum of each column per line not entire file, compare the two then write the... (1 Reply)
Discussion started by: chofred
1 Replies
SPKI(5) 							    Lsh Manuals 							   SPKI(5)

NAME
SPKI - Simple Public Key Infrastructure formats DESCRIPTION
The IETF Simple Public Key Infrastructure Working Group has defined a format for storing, transmitting and manipulating certificates to support security in a wide range of Internet applications which will require the use of public key certificates. For the definition of the SPKI format, please refer to [SPKI]. The format of SPKI objects is a simplified form of S-expression. An S-expression is a list enclosed in matching "(" and ")", similar to the recursive list data structure in of the LISP and Scheme programming languages. Canonical S-expression A canonical S-expression is a unique representation of an S-expression which may contain arbitrary binary byte strings. For transport over a 7-bit channel, it may be base64 (see [RFC2045]) encoded. Advanced S-expression The advanced S-expression format is a complexer form of an S-expression which is not necessarily unique. It is more suited for human read- ing than the canonical S-expression format. EXAMPLE
Examples SPKI certificates can be found in [SPKI]. REFERENCES
<URL:http://www.clark.net/pub/cme/html/spki.html> Home-page of the IETF SPKI working group. <URL:http://theory.lcs.mit.edu/~rivest/sexp.html> Home-page of the S-expression technology. Carl M. Ellison, SPKI Requirements, Internet draft, <URL:http://www.ietf.org/internet-drafts/internet-drafts/draft-ietf-spki-cert-req-02.txt>, 24 October 1998. [SPKI] Carl M. Ellison, Bill Frantz, Butler Lampson, Ron Rivest, Brian M. Thomas and Tatu Ylonen, Simple Public Key Certificate, Internet draft (expired), <URL:http://www.ietf.org/internet-drafts/internet-drafts/draft-ietf-spki-cert-structure-05.txt>, 13 March 1998. Carl M. Ellison, Bill Frantz, Butler Lampson, Ron Rivest, Brian M. Thomas and Tatu Ylonen, SPKI Certificate Theory, Internet draft, <URL:http://www.ietf.org/internet-drafts/internet-drafts/draft-ietf-spki-cert-theory-04.txt>, 17 November 1998. Carl M. Ellison, Bill Frantz, Butler Lampson, Ron Rivest, Brian M. Thomas and Tatu Ylonen, SPKI Examples, Internet draft (expired), <URL:http://www.ietf.org/internet-drafts/draft-ietf-spki-cert-examples-01.txt>, 10 March 1998. [RFC2045] N. Freed and N. Borenstein, Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies, 2 December 1996. AUTHOR
This man-page was written by J.H.M. Dassen (Ray) <jdassen@wi.LeidenUniv.nl>. SEE ALSO
lsh_keygen(1) LSH
JANUARY 1999 SPKI(5)
All times are GMT -4. The time now is 07:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy