I'm starting to understand.
But please explain me the use of [1] and [0]:
I find it a bit confusing/ [0] is the first line from left, [1] is the second and so on, right?
Why did you write [0] in the last map line and [1] in the sort line?
I have some version of AWK that does not support regular expression field separators ( neither do I have nawk or gawk). How do I go about reading a line with the field separator as either the string "=#" or "+=".
My data looks like this:
abhishek=#nnnnn+#1234+#87
One option is to use... (2 Replies)
Hello...
Im trying to use "- " as field separator...
I used awk -F"- " '{print $3}' input_file ... but it's not working, it assumes that the field separator is "-" and not "- " ...
Any ideas ?? :(
Thanks (6 Replies)
Hi, all
I need to get fields in a line that are separated by commas, some of the fields are enclosed with double quotes, and they are supposed to be treated as a single field even if there are commas inside the quotes.
sample input:
for this line, 5 fields are supposed to be extracted, they... (8 Replies)
Hi,
I have a flat file with fields separated by a X'1F'
i have to fetch 4th field from second line.
please help me how to achieve it.
I tried with below command and its not working.
cut -f4 -d`echo -e '\x1f'` filename.txt
I am using SunOS.
Thanks in advance. (2 Replies)
Hi all,
I have an array in BASH and I need to change the IFS in order to split up it correctly.
Here an example:
array_test=(hello world+sunny)
for elem in ${array_test}; do
echo $elem
done
echo -e "\n changed IFS \n"
OLD_IFS=$IFS
IFS=+
for elem in ${array_test}; do
echo... (3 Replies)
Hi,
How i can use two strings as field separator..
I want to use filed separator's as < and >
input -
shdhd ads<adsd adfs >sdfsd sfsdfsd<
Please help me in this..:wall:
thanks a lot... (3 Replies)
Hi !
input:
111|222|333|aaa|bbb|ccc
999|888|777|nnn|kkk
444|666|555|eee|ttt|ooo|ppp
With awk, I am trying to change the FS "|" to "; " only from the 4th field until the end (the number of fields vary between records).
In order to get:
111|222|333|aaa; bbb; ccc
999|888|777|nnn; kkk... (1 Reply)
I need to set awk field separator to ";", but I need to avoid ";EXT".
so that
echo a;b;c;EXTd;e;f | awk -F";" '{print $3}'
would give "c;EXTd" (2 Replies)
Hello All,
I have a file, but I want to separate the file at a particular record with comma"," in the line
Input file
APPLE6SSAMSUNGS5PRICEPERPIECEDOLLAR600EACH010020340URX581949695US
to
Output file
APPLE6S,SAMSUNGS5,PRICEPERPIECE,DOLLAR600EACH,010020340URX581949695,US
This is for... (11 Replies)
Hi All,
I have the input as below:
cat input
032016002 2.891 97.109 16.605 27.172 24.017 32.207 0.233 0.021 39.810 0.077 0.026 19.644 13.882 0.131 11.646 0.102 11.449 76.265 23.735 16.991 83.009 8.840 91.160 0.020 99.980 52.102 47.898 44.004 55.996 39.963 18.625 0.121 1.126 40.189... (15 Replies)
Discussion started by: am24
15 Replies
LEARN ABOUT REDHAT
ldap_sort
LDAP_SORT(3) Library Functions Manual LDAP_SORT(3)NAME
ldap_sort_entries, ldap_sort_values, ldap_sort_strcasecmp - LDAP sorting routines
SYNOPSIS
#include <ldap.h>
ldap_sort_entries(ld, chain, attr, cmp)
LDAP *ld;
LDAPMessage **chain;
char *attr;
int (*cmp)();
ldap_sort_values(ld, vals, cmp)
LDAP *ld;
char **vals;
int (*cmp)();
ldap_sort_strcasecmp(a, b)
char *a;
char *b;
DESCRIPTION
These routines are used to sort lists of entries and values retrieved from an LDAP server. ldap_sort_entries() is used to sort a chain of
entries retrieved from an LDAP search call either by DN or by some arbitrary attribute in the entries. It takes ld, the LDAP structure,
which is only used for error reporting, chain, the list of entries as returned by ldap_search_s(3) or ldap_result(3). attr is the
attribute to use as a key in the sort or NULL to sort by DN, and cmp is the comparison function to use when comparing values (or individual
DN components if sorting by DN). In this case, cmp should be a function taking two single values of the attr to sort by, and returning a
value less than zero, equal to zero, or greater than zero, depending on whether the first argument is less than, equal to, or greater than
the second argument. The convention is the same as used by qsort(3), which is called to do the actual sorting.
ldap_sort_values() is used to sort an array of values from an entry, as returned by ldap_get_values(3). It takes the LDAP connection
structure ld, the array of values to sort vals, and cmp, the comparison function to use during the sort. Note that cmp will be passed a
pointer to each element in the vals array, so if you pass the normal char ** for this parameter, cmp should take two char **'s as arguments
(i.e., you cannot pass strcasecmp or its friends for cmp). You can, however, pass the function ldap_sort_strcasecmp() for this purpose.
For example:
LDAP *ld;
LDAPMessage *res;
/* ... call to ldap_search_s(), fill in res, retrieve sn attr ... */
/* now sort the entries on surname attribute */
if ( ldap_sort_entries( ld, &res, "sn", ldap_sort_strcasecmp ) != 0 )
ldap_perror( ld, "ldap_sort_entries" );
NOTES
The ldap_sort_entries() routine applies the comparison function to each value of the attribute in the array as returned by a call to
ldap_get_values(3), until a mismatch is found. This works fine for single-valued attributes, but may produce unexpected results for multi-
valued attributes. When sorting by DN, the comparison function is applied to an exploded version of the DN, without types. The return
values for all of these functions are declared in the <ldap.h> header file. Some routines may dynamically allocate memory. Callers are
responsible for freeing such memory using the supplied deallocation routines.
SEE ALSO ldap(3), ldap_search(3), ldap_result(3), qsort(3)ACKNOWLEDGEMENTS
OpenLDAP is developed and maintained by The OpenLDAP Project (http://www.openldap.org/). OpenLDAP is derived from University of Michigan
LDAP 3.3 Release.
OpenLDAP 2.0.27-Release 22 September 1998 LDAP_SORT(3)