Sponsored Content
Full Discussion: match field between 2 files
Top Forums Shell Programming and Scripting match field between 2 files Post 302160254 by Klashxx on Monday 21st of January 2008 08:36:46 AM
Old 01-21-2008
Code:
awk 'FNR==NR { a[$1]=$2;next} $1 in a {print $0a[$1] }' FS=":" file1 file2

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

first field match

Hi All, Thanks for your help in advance I am parsing a log file where the first field of each line can have the same key value but not more than 3 times in a row. Varying value of that first field changes as you go through the log but it either appears 3 times or two and sometimes only once.... (1 Reply)
Discussion started by: dragrid
1 Replies

2. Shell Programming and Scripting

Script to Match first field of two Files and print

Hi, I want to get script or command in Sun Unix which matches first fields of both the files and print the feilds of one files, example may make it more clear. InputFile1 ================== Alex,1,fgh Menthos,45454,toto Gothica,855,ee Zenie4,77,gg Salvatore,66,oo Dhin,1234,papapa... (3 Replies)
Discussion started by: indian.ace
3 Replies

3. Shell Programming and Scripting

Match two files and divide a field !

Hello, I have two files that have the date field as a common. I request your help with some script that divide the value of the file1 by the value in the file2 only when the field date are the same between both files and create a new text file. This is a sample of the files file1... (1 Reply)
Discussion started by: csierra
1 Replies

4. Shell Programming and Scripting

AWK: Pattern match between 2 files, then compare a field in file1 as > or < field in file2

First, thanks for the help in previous posts... couldn't have gotten where I am now without it! So here is what I have, I use AWK to match $1 and $2 as 1 string in file1 to $1 and $2 as 1 string in file2. Now I'm wondering if I can extend this AWK command to incorporate the following: If $1... (4 Replies)
Discussion started by: right_coaster
4 Replies

5. UNIX for Dummies Questions & Answers

Match pattern in a field, print pattern only instead of the entire field

Hi ! I have a tab-delimited file, file.tab: Column1 Column2 Column3 aaaaaaaaaa bbtomatoesbbbbbb cccccccccc ddddddddd eeeeappleseeeeeeeee ffffffffffffff ggggggggg hhhhhhtomatoeshhh iiiiiiiiiiiiiiii ... (18 Replies)
Discussion started by: lucasvs
18 Replies

6. Shell Programming and Scripting

Match complete field

hello, i have a little problem, i want match the complete field ($1 or $2) with a complete word in another variable. example: i have a file with either one or two words per lane: hsa-mir-4449 hsa-mir-4707 hsa-mir-4707* hsa-mir-4707 novelMiR_3551 novelMiR_3563 novelMiR_4330... (4 Replies)
Discussion started by: ace13
4 Replies

7. Shell Programming and Scripting

Match columns from two csv files and update field in one of the csv file

Hi, I have a file of csv data, which looks like this: file1: 1AA,LGV_PONCEY_LES_ATHEE,1,\N,1,00020460E1,0,\N,\N,\N,\N,2,00.22335321,0.00466628 2BB,LES_POUGES_ASF,\N,200,200,00006298G1,0,\N,\N,\N,\N,1,00.30887539,0.00050312... (10 Replies)
Discussion started by: djoseph
10 Replies

8. Shell Programming and Scripting

Command/script to match a field and print the next field of each line in a file.

Hello, I have a text file in the below format: Source Destination State Lag Status CQA02W2K12pl:D:\CAQA ... (10 Replies)
Discussion started by: pocodot
10 Replies

9. Shell Programming and Scripting

awk to match value to a field within +/- value

In the awk below I use $2 of filet to search filea for a match. If the values in $2 are exact match this works great. However, that is not always the case, so I need to perform the search using a range of + or - 2. That is if the value in filea $2 is within + or - 2 of filet $2 then it is matched.... (6 Replies)
Discussion started by: cmccabe
6 Replies

10. Shell Programming and Scripting

awk to match field between two files and use conditions on match

I am trying to look for $2 of file1 (skipping the header) in $2 of file2 (skipping the header) and if they match and the value in $10 is > 30 and $11 is > 49, then print the line from file1 to a output file. If no match is foung the line is not printed. Both the input and output are tab-delimited.... (3 Replies)
Discussion started by: cmccabe
3 Replies
IMAP_SEARCH(3)								 1							    IMAP_SEARCH(3)

imap_search - This function returns an array of messages matching the given search criteria

SYNOPSIS
array imap_search (resource $imap_stream, string $criteria, [int $options = SE_FREE], [string $charset = NIL]) DESCRIPTION
This function performs a search on the mailbox currently opened in the given IMAP stream. For example, to match all unanswered messages sent by Mom, you'd use: "UNANSWERED FROM mom". Searches appear to be case insensitive. This list of criteria is from a reading of the UW c-client source code and may be incomplete or inaccurate (see also RFC2060, section 6.4.4). PARAMETERS
o $ imap_stream -An IMAP stream returned by imap_open(3). o $criteria - A string, delimited by spaces, in which the following keywords are allowed. Any multi-word arguments (e.g. FROM "joey smith") must be quoted. Results will match all $criteria entries. o ALL - return all messages matching the rest of the criteria o ANSWERED - match messages with the \ANSWERED flag set o BCC "string" - match messages with "string" in the Bcc: field o BEFORE "date" - match messages with Date: before "date" o BODY "string" - match messages with "string" in the body of the message o CC "string" - match messages with "string" in the Cc: field o DELETED - match deleted messages o FLAGGED - match messages with the \FLAGGED (sometimes referred to as Important or Urgent) flag set o FROM "string" - match messages with "string" in the From: field o KEYWORD "string" - match messages with "string" as a keyword o NEW - match new messages o OLD - match old messages o ON "date" - match messages with Date: matching "date" o RECENT - match messages with the \RECENT flag set o SEEN - match messages that have been read (the \SEEN flag is set) o SINCE "date" - match messages with Date: after "date" o SUBJECT "string" - match messages with "string" in the Subject: o TEXT "string" - match messages with text "string" o TO "string" - match messages with "string" in the To: o UNANSWERED - match messages that have not been answered o UNDELETED - match messages that are not deleted o UNFLAGGED - match messages that are not flagged o UNKEYWORD "string" - match messages that do not have the keyword "string" o UNSEEN - match messages which have not been read yet o $options - Valid values for $options are SE_UID, which causes the returned array to contain UIDs instead of messages sequence numbers. o $charset - RETURN VALUES
Returns an array of message numbers or UIDs. Return FALSE if it does not understand the search $criteria or no messages have been found. EXAMPLES
Example #1 imap_search(3) example <?php $conn = imap_open('{imap.example.com:993/imap/ssl}INBOX', 'foo@example.com', 'pass123', OP_READONLY); $some = imap_search($conn, 'SUBJECT "HOWTO be Awesome" SINCE "8 August 2008"', SE_UID); $msgnos = imap_search($conn, 'ALL'); $uids = imap_search($conn, 'ALL', SE_UID); print_r($some); print_r($msgnos); print_r($uids); ?> The above example will output something similar to: Array ( [0] => 4 [1] => 6 [2] => 11 ) Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 ) Array ( [0] => 1 [1] => 4 [2] => 6 [3] => 8 [4] => 11 [5] => 12 ) SEE ALSO
imap_listscan(3). PHP Documentation Group IMAP_SEARCH(3)
All times are GMT -4. The time now is 02:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy