09-19-2007
Filtering Data
file1 contain: (this just a small sample of data it may have thousand of lines)
1 aaa 1/01/1975 delhi
2 bbb 2/03/1977 mumbai
3 ccc 1/01/1975 mumbai
4 ddd 2/03/1977 chennai
5 aaa 1/01/1975 kolkatta
6 bbb 2/03/1977 bangalore
program:
nawk '{
idx= $2 SUBSEP $3
arr[idx] = (idx in arr) ? arr[idx] ORS $0 : $0
arrCnt[idx]++
}
END {
for (i in arr)
if (arrCnt[i] > 1) print arr[i]
}' file1
Result:
2 bbb 2/03/1977 mumbai
6 bbb 2/03/1977 bangalore
1 aaa 1/01/1975 delhi
5 aaa 1/01/1975 kolkatta
Questions:
How the code should be if I need the data result to be like this :
1 aaa 1/01/1975 delhi
3 ccc 1/01/1975 mumbai
2 bbb 2/03/1977 mumbai
4 ddd 2/03/1977 chennai
Please help! Thank you friends!
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I have following command which tells me File size in GBs which are greater than 0.01GBs recursively in a dir structure.
ls -l -R | awk '{ if ($5/1073741824 >= 0.01) print $9, $5/1073741824 }'
But there are some files whom I dont have enough permissions, after executing this script
gives me... (1 Reply)
Discussion started by: videsh77
1 Replies
2. Shell Programming and Scripting
Hi All,
I have the below input and expected ouput. I need a code which can scan through this input file and if the number in column1 is more than 1 , it will print out the whole line, else it will output "No Re-occurrence". Can anybody help ?
Input:
1 vvvvv 20 7 7 23 0 64
6 zzzzzz 11 5... (7 Replies)
Discussion started by: Raynon
7 Replies
3. Shell Programming and Scripting
Hello Gurus,
Please help me out of the problem. I ve a input file as below
input clock;
input a; //reset all
input b;
//input comment
output c;
output d;
output e;
input f;
//output comment
I need the output as follows:
\\Inputs (1 Reply)
Discussion started by: user_prady
1 Replies
4. Shell Programming and Scripting
Hi ,
i have file with delimiter as "|" and data in Double codes for all fields. how to filter data in a column like awk -F"|" '$1="asdf" {print $0}' test.
ex : "asdf"|"zxcv"
Thanks,
Soma (1 Reply)
Discussion started by: challamsomu
1 Replies
5. Shell Programming and Scripting
I am trying to filter out some data with awk. If someone could help me that would be great. Below is my input file.
Date: 10-JUN-12 12:00:00
B 0: 00 00 00 00 10 00 16 28
B 120: 00 00 00 39 53 32 86 29
Date: 10-JUN-12 12:00:10
B 0: 00 00 00 00 10 01 11 22
B 120: 00 00 00 29 23 32 16 29... (5 Replies)
Discussion started by: thibodc
5 Replies
6. Homework & Coursework Questions
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
my data in csv-format ...
...
13/08/2012,16:30,303.30,5.10,3,2,2,1,9360.0,322... (13 Replies)
Discussion started by: IMPe
13 Replies
7. Shell Programming and Scripting
Hello,
Does anyone know an easy way to filter this type of file? I want to get everything that has score (column 2) 100.00 and get rid of duplicates (for example gi|332198263|gb|EGK18963.1| below), so I guess uniq can be used for this?
gi|3379182634|gb|EGK18561.1| 100.00... (6 Replies)
Discussion started by: narachaid
6 Replies
8. Shell Programming and Scripting
Hi,
I have some data like seen below.
format : apple(hhmm mm/dd).fruit
apple(2345 03/25).fruit
apple(2345 05/06).fruit
orange(0443 05/02).fruit
orange(0345 05/05).fruit
orange(2134 05/04).fruit
grape(0930 04/24).fruit
grape(2330 03/30).fruit
I need to get the data which are... (1 Reply)
Discussion started by: jayadanabalan
1 Replies
9. Shell Programming and Scripting
Please consider the following file, I have many groups which can be of 3 types, T1 (Serial_Number 1) T2 (Serial_Number 2) and T1*T2 (all other Serial_Number).
I want to only consider groups that have both T1 and T2 present and their values are different from each other. In the example file,... (8 Replies)
Discussion started by: jianp83
8 Replies
10. Shell Programming and Scripting
Hi Everyone,
I need help on figuring out a way to filter some data that I get back from an API. Im able to get all the data that Im looking for but I would like to know a way for me to filter it better. The data that Im getting back is basically 2 rows of data as seen here.
Row 1 ... (25 Replies)
Discussion started by: TheStruggle
25 Replies
LEARN ABOUT DEBIAN
data::ical::entry::timezone::standard
Data::ICal::Entry::TimeZone::Standard(3pm) User Contributed Perl Documentation Data::ICal::Entry::TimeZone::Standard(3pm)
NAME
Data::ICal::Entry::TimeZone::Standard - Represents a Standard Time base offset from UTC for parent TimeZone
DESCRIPTION
A time zone is unambiguously defined by the set of time measurement rules determined by the governing body for a given geographic area.
These rules describe at a minimum the base offset from UTC for the time zone, often referred to as the Standard Time offset. Many locations
adjust their Standard Time forward or backward by one hour, in order to accommodate seasonal changes in number of daylight hours, often
referred to as Daylight Saving Time. Some locations adjust their time by a fraction of an hour. Standard Time is also known as Winter Time.
Daylight Saving Time is also known as Advanced Time, Summer Time, or Legal Time in certain countries. The following table shows the changes
in time zone rules in effect for New York City starting from 1967. Each line represents a description or rule for a particular observance.
Effective Observance Rule
Date (Date/Time) Offset Abbreviation
1967-* last Sun in Oct, 02:00 -0500 EST
1967-1973 last Sun in Apr, 02:00 -0400 EDT
1974-1974 Jan 6, 02:00 -0400 EDT
1975-1975 Feb 23, 02:00 -0400 EDT
1976-1986 last Sun in Apr, 02:00 -0400 EDT
1987-* first Sun in Apr, 02:00 -0400 EDT
Note: The specification of a global time zone registry is not addressed by this document and is left for future study. However,
implementers may find the Olson time zone database [TZ] a useful reference. It is an informal, public-domain collection of time zone
information, which is currently being maintained by volunteer Internet participants, and is used in several operating systems. This
database contains current and historical time zone information for a wide variety of locations around the globe; it provides a time zone
identifier for every unique time zone rule set in actual use since 1970, with historical data going back to the introduction of standard
time.
METHODS
ical_entry_type
Returns "STANDARD", its iCalendar entry name.
mandatory_unique_properties
According to the iCalendar standard, the following properties must be specified exactly one time in a standard time declaration:
dtstart tzoffsetto tzoffsetfrom
optional_repeatable_properties
According to the iCalendar standard, the following properties may be specified any number of times for a standard time declaration:
comment rdate rrule tzname
AUTHOR
Jesse Vincent "<jesse@bestpractical.com>" with David Glasser, Simon Wistow, Alex Vandiver
LICENCE AND COPYRIGHT
Copyright (c) 2005 - 2009, Best Practical Solutions, LLC. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
DISCLAIMER OF WARRANTY
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT
WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
perl v5.14.2 2009-07-16 Data::ICal::Entry::TimeZone::Standard(3pm)