Sponsored Content
Top Forums Shell Programming and Scripting Identifying entries based on 2 fields in a string. Post 302601964 by wabbit02 on Saturday 25th of February 2012 08:46:02 AM
Old 02-25-2012
Identifying entries based on 2 fields in a string.

Hi Guys,

I’m struggling to use two fields to do a duplicate/ unique by output.

I want to look IP addresses assigned to more than one account during a given period in the logs. So duplicate IP and account > 1 then print all the logs for that IP. I have been Using AWK (just as its installed on the system in question). Any help would be greatly appreciated.

log:
Code:
2012/01/01:01:30:35  type: 1, ip-assigned: 10.10.10.236, account: E8C200511C63, 
2012/01/01:01:30:36  type: 2, ip-assigned: 10.10.10.236, account: E8C200511C63, 
2012/01/01:01:30:37  type: 1, ip-assigned: 10.10.10.37, account: E8C3004BF14E,
2012/01/01:01:30:38  type: 2, ip-assigned: 10.10.10.11, account: E8C201111C63,
2012/01/01:01:30:39  type: 1, ip-assigned: 10.10.10.228, account: E8C300314D4A, 
2012/01/01:01:30:40  type: 2, ip-assigned: 10.10.10.147, account: E8C30031407A, 
2012/01/01:01:30:41  type: 1, ip-assigned: 10.10.10.236, account: E8C3003149CA, 
2012/01/01:01:30:42  type: 2, ip-assigned: 10.10.10.37, account: E8C3004BF14E, 
2012/01/01:01:30:43  type: 1, ip-assigned: 10.10.10.37, account: E8C3007069AD,
2012/01/01:01:30:44  type: 1, ip-assigned: 10.10.10.11, account: E8C201DB1C63,
2012/01/01:01:30:45  type: 2, ip-assigned: 10.10.10.228, account: E8C300314D4A, 
2012/01/01:01:30:46  type: 1, ip-assigned: 10.10.10.230, account: E8C300314D4A, 
2012/01/01:01:30:47  type: 2, ip-assigned: 10.10.10.230, account: E8C300314D4A,
2012/01/01:01:30:48  type: 1, ip-assigned: 10.10.10.101, account: E8C200511C63,

Desired output;
Code:
2012/01/01:01:30:35  type: 1, ip-assigned: 10.10.10.236, account: E8C200511C63, 
2012/01/01:01:30:36  type: 2, ip-assigned: 10.10.10.236, account: E8C200511C63, 
2012/01/01:01:30:41  type: 1, ip-assigned: 10.10.10.236, account: E8C3003149CA, 
2012/01/01:01:30:37  type: 1, ip-assigned: 10.10.10.37, account: E8C3004BF14E,
2012/01/01:01:30:42  type: 2, ip-assigned: 10.10.10.37, account: E8C3004BF14E, 
2012/01/01:01:30:43  type: 1, ip-assigned: 10.10.10.37, account: E8C3007069AD,
2012/01/01:01:30:38  type: 2, ip-assigned: 10.10.10.11, account: E8C201111C63,
2012/01/01:01:30:44  type: 1, ip-assigned: 10.10.10.11, account: E8C201DB1C63,


Last edited by Franklin52; 02-26-2012 at 05:13 AM.. Reason: Please use code tags for data and code samples, thank you
 

9 More Discussions You Might Find Interesting

1. Solaris

Identifying new fields of data

i have hundreds of lines of formatted data with 10 different fields per line. the data is refreshed every few minutes and some fields in some lines may reflect new data. i'm looking for a sample of code that help me to identify those new fields so that i can write them to a file to indicate that... (0 Replies)
Discussion started by: davels
0 Replies

2. Shell Programming and Scripting

Identifying a string from a set of files and printing to a new file

Dear All, I'm an amateur to writing scripts and need to do the following Need to read all files with a .log extension in a directory and identify the value for username i.e. all files have something like username = John. Once this is read, I need to print this value to a new file. The new file... (2 Replies)
Discussion started by: Kelly_B
2 Replies

3. Shell Programming and Scripting

Identifying specific fields in a Row

Hi, I am new to UNIX. Can some one help me to solve the below. I have a requirement to to identify the specific fields in row and also some part of the field. In my file I have a record as sundra;10.44.48.65;10thstreet TCP packet out of state: First packet isn't SYN;telno:... (3 Replies)
Discussion started by: suneel.mekala
3 Replies

4. Shell Programming and Scripting

Help identifying the first word in a string

Hi all, I'd like to know how to identify the first word in a string (in bash) for e.g. echo "enter your name" read name (user enters 'Joe Bloggs' for e.g.) echo "hello $name" (output says "hello Joe") Thanks for any help (5 Replies)
Discussion started by: kazazza
5 Replies

5. Shell Programming and Scripting

Awk - Script assistance on identifying non matching fields

Hoping for some assistance. my source file consists of: os, ip, username win7, 123.56.78, john win7, 123.56.78, paul win7, 10.1.1.1, john win7, 10.2.2.3, joe I've been trying to run a script that will only return ip and username where the IP address is the same and the username is... (3 Replies)
Discussion started by: tekvaio
3 Replies

6. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

7. Shell Programming and Scripting

Identifying columns and their values based on schema file

I have 3 files, data file,schema file and a threshold file. Data file contains data in which columns are distributed according to schema file. This data file doesn't contain any headers. Three continuous columns in the data file represent single variable in schema file. first column represent... (1 Reply)
Discussion started by: bharathbangalor
1 Replies

8. Shell Programming and Scripting

Find and replace string based on entries on another file

I have a file1 with different with multiple fields and records File2 has 2 fields. I want to find and replace strings in file1 based on file2 values (I Want an exact match i.e. for example: when searching for DT:3, Substr of DT:34 should not be matched) File2: DT:3 foo_err DT:34 bar_frr... (8 Replies)
Discussion started by: aydj
8 Replies

9. Shell Programming and Scripting

awk sort based on difference of fields and print all fields

Hi I have a file as below <field1> <field2> <field3> ... <field_num1> <field_num2> Trying to sort based on difference of <field_num1> and <field_num2> in desceding order and print all fields. I tried this and it doesn't sort on the difference field .. Appreciate your help. cat... (9 Replies)
Discussion started by: newstart
9 Replies
aclsort(3C)															       aclsort(3C)

NAME
aclsort() - sort an Access Control List (JFS File Systems only) SYNOPSIS
DESCRIPTION
The routine sorts JFS Access Control List (ACL) entries into the correct order to be accepted by the acl(2) system call. points to a buffer containing ACL entries; if non-zero, indicates that the permissions should be recalculated; and specifies the number of ACL entries in the buffer. sorts the contents of the ACL buffer as follows: Entries will be in order and Entries of type and will be sorted in increasing order by numeric ID. The call will succeed if all of the following are true: There is exactly one entry each of type and There is at most one entry each of type and Entries of type or may not contain duplicate entries. A duplicate entry is one of the same type containing the same numeric id, irrespective of permission bits. If the argument is zero and there are no entries of type and no entries of type the permissions of the and entries must be the same. If there are no entries of type and no entries of type and the entry is specified, then the entry must also be specified, and the permissions of the and entries must be the same. RETURN VALUE
Upon successful completion, the return value is 0. If there are duplicate entries, the return value is the position of the first duplicate entry. If there is more than one entry of type or they are treated as duplicate entries, and the return value is the position of the first duplicate entry. For all other errors, the return value is -1. NOTICES
The buffer is sorted by type and ID before checking for any failures. Therefore the buffer is always sorted, even if there is a failure. The position of a duplicate entry returned on failure is not the byte offset of the duplicate entry from its base; rather it refers to the entry number of the duplicate entry within the sorted buffer. Checks will be performed in order of entry type. If there are multiple failures, the failure returned will be the first encountered, for example, if the ACL buffer contains a duplicate entry and does not contain an entry, the return value will be the first duplicate entry. ACLs do not have to be sorted with prior to passing them to acl(2). DEPENDENCIES
is supported only on JFS file systems on the standard HP-UX operating system. AUTHOR
was developed by AT&T. SEE ALSO
acl(2), aclv(5). aclsort(3C)
All times are GMT -4. The time now is 10:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy