Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to Sort Records Uniquely? Post 302168514 by earnstaf on Monday 18th of February 2008 04:21:25 PM
Old 02-18-2008
Quote:
Originally Posted by radoulov
Yes:

Code:
awk 'NF{x[$0]++}END{for(k in x)printf "%s\ncount: %d\n%\n",k,x[k]} ' RS="%" filename

Very nice radoulov... thanks for all your help. One final question: Can you think of any way to sort the records based on the output of count? Is it possible with awk? Sort can't do it due to my original problem of sorting not treating my records as full records.
 

10 More Discussions You Might Find Interesting

1. Solaris

How to remove duplicate records with out sort

Can any one give me command How to delete duplicate records with out sort. Suppose if the records like below: 345,bcd,789 123,abc,456 234,abc,456 712,bcd,789 out tput should be 345,bcd,789 123,abc,456 Key for the records is 2nd and 3rd fields.fields are seperated by colon(,). (2 Replies)
Discussion started by: svenkatareddy
2 Replies

2. Shell Programming and Scripting

How to remove duplicate records with out sort

Can any one give me command How to delete duplicate records with out sort. Suppose if the records like below: 345,bcd,789 123,abc,456 234,abc,456 712,bcd,789 out tput should be 345,bcd,789 123,abc,456 Key for the records is 2nd and 3rd fields.fields are seperated by colon(,). (19 Replies)
Discussion started by: svenkatareddy
19 Replies

3. Shell Programming and Scripting

Sort & Split records in a file

Hi, I am new to scripting. I need a script to sort and the records in a file and then split them into different files. For example, the file is: H1...................... H2...................... D2.................... D2.................... H1........................... (15 Replies)
Discussion started by: Sunitha_edi82
15 Replies

4. Shell Programming and Scripting

Based on num of records in file1 need to check records in file2 to set some condns

Hi All, I have two files say file1 and file2. I want to check the number of records in file1 and if its atleast 2 (i.e., 2 or greater than 2 ) then I have to check records in file2 .If records in file2 is atleast 1 (i.e. if its not empty ) i have to set some conditions . Could you pls... (3 Replies)
Discussion started by: mavesum
3 Replies

5. Shell Programming and Scripting

sort a file which has 3.7 million records

hi, I'm trying to sort a file which has 3.7 million records an gettign the following error...any help is appreciated... sort: Write error while merging. Thanks (6 Replies)
Discussion started by: greenworld
6 Replies

6. Shell Programming and Scripting

Unix sort for fixed length columns and records

I was trying to use the AIX 6.1 sort command to sort fixed-length data records, sorting by specific columns only. It took some time to figure out how to get it to work, so I wanted to share the solution. The sort man page wasn't much help, because it talks about field delimeters (default space... (1 Reply)
Discussion started by: CheeseHead1
1 Replies

7. UNIX for Dummies Questions & Answers

Alphabetical sort for multi line records contains in a single file

Hi all, I So, I've got a monster text document comprising a list of various company names and associated info just in a long list one after another. I need to sort them alphabetically by name... The text document looks like this: Company Name: the_first_company's_name_here Address:... (2 Replies)
Discussion started by: quee1763
2 Replies

8. UNIX for Advanced & Expert Users

How to uniquely distinguish between two USB ports??

Hi all, I am facing a problem while writing a shell script. My machine has two USB ports- left port and right port. whenever I connect USBS to both the ports, entry is generated as /sys/block/sdc and /sys/block/sdd and I mount the USBs to a particular directory. But I need to know... (3 Replies)
Discussion started by: Pkumar Sachin
3 Replies

9. Shell Programming and Scripting

How to read records in a file and sort it?

I have a file which has number of pipe delimited records. I am able to read the records....but I want to sort it after reading. i=0 while IFS="|" read -r usrId dataOwn expire email group secProf startDt endDt smhRole RoleCat DataProf SysRole MesgRole SearchProf do print $usrId $dataOwn... (4 Replies)
Discussion started by: harish468
4 Replies

10. UNIX for Beginners Questions & Answers

Extract delta records using with "comm" and "sort" commands combination

Hi All, I have 2 pipe delimited files viz., file_old and file_new. I'm trying to compare these 2 files, and extract all the different rows between them into a new_file. comm -3 < sort file_old < sort file_new > new_file I am getting the below error: -ksh: sort: cannot open But if I do... (7 Replies)
Discussion started by: njny
7 Replies
Net::LDAP::Control::SortResult(3pm)			User Contributed Perl Documentation		       Net::LDAP::Control::SortResult(3pm)

NAME
Net::LDAP::Control::SortResult - Server Side Sort (SSS) result control object SYNOPSIS
use Net::LDAP::Control::Sort; use Net::LDAP::Constant qw(LDAP_CONTROL_SORTRESULT); use Net::LDAP::Util qw(ldap_error_name); $sort = Net::LDAP::Control::Sort->new( order => "cn -age" ); $mesg = $ldap->search( @args, control => [ $sort ]); ($resp) = $mesg->control( LDAP_CONTROL_SORTRESULT ); if ($resp) { if ($resp->result) { my $attr = $resp->attr; print "Problem sorting, ",ldap_error_name($resp->result); print " ($attr)" if $attr; print " "; } else { print "Results are sorted "; } } else { print "Server does not support sorting "; } DESCRIPTION
"Net::LDAP::Control::SortResult" is a sub-class of Net::LDAP::Control. It provides a class for manipulating the LDAP sort request control 1.2.840.113556.1.4.474 as defined in RFC-2891 A sort result control will be returned by the server in response to a search with a Server Side Sort control. If a sort result control is not returned then the user may assume that the server does not support sorting and the results are not sorted. CONSTRUCTOR ARGUMENTS
attr If "result" indicates that there was a problem with sorting and that problem was due to one of the attributes specified in the sort control. "attr" is set to the name of the attribute causing the problem. result This is the result code that describes if the sort operation was sucessful. If will be one of the result codes describes below. METHODS
As with Net::LDAP::Control each constructor argument described above is also available as a method on the object which will return the current value for the attribute if called without an argument, and set a new value for the attribute if called with an argument. RESULT CODES
Possible results from a sort request are listed below. See Net::LDAP::Constant for a definition of each. LDAP_SUCCESS LDAP_OPERATIONS_ERROR LDAP_TIMELIMIT_EXCEEDED LDAP_STRONG_AUTH_REQUIRED LDAP_ADMIN_LIMIT_EXCEEDED LDAP_NO_SUCH_ATTRIBUTE LDAP_INAPPROPRIATE_MATCHING LDAP_INSUFFICIENT_ACCESS LDAP_BUSY LDAP_UNWILLING_TO_PERFORM LDAP_OTHER SEE ALSO
Net::LDAP, Net::LDAP::Control::Sort, Net::LDAP::Control, http://ww.ietf.org/rfc/rfc2891.txt AUTHOR
Graham Barr <gbarr@pobox.com> Please report any bugs, or post any suggestions, to the perl-ldap mailing list <perl-ldap@perl.org> COPYRIGHT
Copyright (c) 1999-2004 Graham Barr. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-01-29 Net::LDAP::Control::SortResult(3pm)
All times are GMT -4. The time now is 07:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy