Sponsored Content
Full Discussion: Sort references
Top Forums UNIX for Dummies Questions & Answers Sort references Post 302903543 by drl on Wednesday 28th of May 2014 10:30:33 AM
Old 05-28-2014
Hi.

Utility msort provides for paragraph sorts among its many options:
Code:
#!/usr/bin/env bash

# @(#) s1	Demonstrate sort by paragraphs, msort.
# See msort in repository or at:
# http://freecode.com/projects/msort

# Utility functions: print-as-echo, print-line-with-visual-space, debug.
# export PATH="/usr/local/bin:/usr/bin:/bin"
LC_ALL=C ; LANG=C ; export LC_ALL LANG
pe() { for _i;do printf "%s" "$_i";done; printf "\n"; }
pl() { pe;pe "-----" ;pe "$*"; }
db() { ( printf " db, ";for _i;do printf "%s" "$_i";done;printf "\n" ) >&2 ; }
db() { : ; }
C=$HOME/bin/context && [ -f $C ] && $C msort

FILE=${1-data1}

pl " Input data file $FILE:"
cat $FILE

pl " Results:"
msort -q -b -w $FILE

exit 0

producing:
Code:
$ ./s1

Environment: LC_ALL = C, LANG = C
(Versions displayed with local utility "version")
OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution        : Debian 5.0.8 (lenny, workstation) 
bash GNU bash 3.2.39
msort 8.44

-----
 Input data file data1:
Anderson, E.R., Duvall, T.L., Jr., and Jefferies, S.M., 1990. Modelling 
     of Solar Oscilation Power Spectra. The Astrophysical Journal, vol. 364, 
     p. 699.

Duvall, T.L., Jr., and Harvey, J.W., 1986. Solar Doppler Shifts: Sources 
     of Continuous Spectra. In Seismology of the Sun and the Distant Stars, 
     (ed. D. Gough), NATO A Ser., Reidel, Dordrecht, p. 105.

Basu, S., Antia, H.M., and Tripathy, S.C. 1999. Ring Diagram Analysis
     of Near-Surface Flow in the Sun. The Astrophysical Journal, vol. 512, 
     pp. 458-470.

Nigam, R., Kosovichev, A.G., Scherrer, P.H., and Schou, J., 1998. 
     Asymmetry in Velocity and Intensity Helioseismic Spectra: A solution 
     to a long-standing puzzle. The Astrophysical Journal, vol. 495, 
     pp. L115-L118.

-----
 Results:
Anderson, E.R., Duvall, T.L., Jr., and Jefferies, S.M., 1990. Modelling 
     of Solar Oscilation Power Spectra. The Astrophysical Journal, vol. 364, 
     p. 699.

Basu, S., Antia, H.M., and Tripathy, S.C. 1999. Ring Diagram Analysis
     of Near-Surface Flow in the Sun. The Astrophysical Journal, vol. 512, 
     pp. 458-470.

Duvall, T.L., Jr., and Harvey, J.W., 1986. Solar Doppler Shifts: Sources 
     of Continuous Spectra. In Seismology of the Sun and the Distant Stars, 
     (ed. D. Gough), NATO A Ser., Reidel, Dordrecht, p. 105.

Nigam, R., Kosovichev, A.G., Scherrer, P.H., and Schou, J., 1998. 
     Asymmetry in Velocity and Intensity Helioseismic Spectra: A solution 
     to a long-standing puzzle. The Astrophysical Journal, vol. 495, 
     pp. L115-L118.

The options are quiet, record is a block, sort entire text of record. These may be refined as necessary.

Best wishes ... cheers, drl
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

IRIX books, manuals, references...

Does anyone out there know of ANY specific books pertaining to SGI's flavor of Unix - IRIX? I have been in contact with SGI directly and they have not supplied me with any usable reference material or manuals. I realize man pages are a good source for info, but I need to go a little deeper... (6 Replies)
Discussion started by: lozinit
6 Replies

2. AIX

AIX References?

Would like to know where or what is available to quickly develope my AIX skills. Training budget limited.. Thanks and have a great day! (1 Reply)
Discussion started by: lmwical
1 Replies

3. UNIX for Advanced & Expert Users

Compound indirect variable references

Using bash, I'm trying to read a .properties file (name=value pairs), assigning an indirect variable reference for each line in the file. The trick is that a property's value string may contain the name of a property that occurred earlier in the file, and I want the name of the 1st property to... (5 Replies)
Discussion started by: tkrussel
5 Replies

4. Programming

Wanted: References on Sockets and Threads for C

I'm looking at http://www.opengroup.org/pubs/online/7908799/xsh/pthread.h.html trying to understand mutexs and semaphores. Windows makes a distinction between the two. Is a mutex and semaphore different in unix land? Is there a tutorial on threading in unix somewhere? I'm also looking at... (4 Replies)
Discussion started by: siegfried
4 Replies

5. Shell Programming and Scripting

perl - passing hash references to functions

hi there I have the following script in which i have created a PrintHash() function. I want to pass to this function the reference to a hash (in the final code i will be passing different hashes to this print function hence the need for a function). I am getting an error Type of arg 1 to... (1 Reply)
Discussion started by: hcclnoodles
1 Replies

6. Shell Programming and Scripting

Perl References/Dereferences

Can someone explain where can we actually used print $var->; or print $$var When does the -> becomes necessary and when its optional. (1 Reply)
Discussion started by: dinjo_jo
1 Replies

7. Shell Programming and Scripting

Strip one of two Patch references

This log file is wacky. the syntax puts this in the Installation line: Installation PATCH75682.91 of PATCH75681 complete Installation PATCH76537.91 of PATCH76537 complete Installation PATCH92217.91 of PATCH92217 complete So I'm looking for a sed 's///' to remove the first PATCHxxxx... (6 Replies)
Discussion started by: dba_frog
6 Replies

8. Shell Programming and Scripting

Query related to references in array in Perl

Hi All I have a doubt and want to be cleared I am using @array = (10, 20); $rarray = \@array; #print "$rarray\n"; #print "@$rarray\n"; $rr= \$array; #print $$rr; $rr++; print $$rr; As you can see the $rr contains the reference to the first element of the array , now as the... (5 Replies)
Discussion started by: parthmittal2007
5 Replies

9. Shell Programming and Scripting

awk Programming references

Hi all, I am new and I am very interested in Awk programming language and would like to know what references or books that really worked for you that was clear, concise with simple examples. much appreciated in advance. (1 Reply)
Discussion started by: Apollo
1 Replies
Net::LDAP::Control::Sort(3)				User Contributed Perl Documentation			       Net::LDAP::Control::Sort(3)

NAME
Net::LDAP::Control::Sort - Server Side Sort (SSS) control object SYNOPSIS
use Net::LDAP::Control::Sort; use Net::LDAP::Constant qw(LDAP_CONTROL_SORTRESULT); $sort = Net::LDAP::Control::Sort->new( order => "cn -phone" ); $mesg = $ldap->search( @args, control => [ $sort ]); ($resp) = $mesg->control( LDAP_CONTROL_SORTRESULT ); print "Results are sorted " if $resp and !$resp->result; DESCRIPTION
"Net::LDAP::Control::Sort" is a sub-class of Net::LDAP::Control. It provides a class for manipulating the LDAP Server Side Sort (SSS) request control 1.2.840.113556.1.4.473 as defined in RFC-2891 If the server supports sorting, then the response from a search operation will include a sort result control. This control is handled by Net::LDAP::Control::SortResult. CONSTRUCTOR ARGUMENTS
order A string which defines how entries may be sorted. It consists of multiple directives, separated by whitespace. Each directive describes how to sort entries using a single attribute. If two entries have identical attributes, then the next directive in the list is used. Each directive specifies a sorting order as follows -attributeType:orderingRule The leading "-" is optional, and if present indicates that the sorting order should be reversed. "attributeType" is the attribute name to sort by. "orderingRule" is optional and indicates the rule to use for the sort and should be valid for the given "attributeType". Any one attributeType should only appear once in the sorting list. Examples "cn" sort by cn using the default ordering rule for the cn attribute "-cn" sort by cn using the reverse of the default ordering rule "age cn" sort by age first, then by cn using the default ordering rules "cn:1.2.3.4" sort by cn using the ordering rule defined as 1.2.3.4 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. SEE ALSO
Net::LDAP, Net::LDAP::Control::SortResult, Net::LDAP::Control, http://www.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.18.2 2013-07-21 Net::LDAP::Control::Sort(3)
All times are GMT -4. The time now is 11:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy