08-18-2008
My friends this is not HW it's just challenge between my friends
Anyway i try to solve it:
grep -c | sort -u test.txt | tr -d "\t \v \f [unct:] [:upper:] "
but actually i don't know how i can sort this commands ?? so anybody can correct it for me.
Thanks everyone replayed to me.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
hi,
cud u help me to find this.
i hav 2 files.
file1 has data as "ARUN
ARUN is from Australia
Arun likes America etc..
ARUN ARUN "
file2 has "ARUN
Australia
America"
i... (5 Replies)
Discussion started by: arunsubbhian
5 Replies
2. UNIX for Advanced & Expert Users
Hi
I'm looking for a .ksh script/function that will calculate ONLY the number of days between two distinct dates. Further convert the number of days to weeks and display. I need this to be part of another larger script that checks the password expiry on several servers and notifies the... (1 Reply)
Discussion started by: radheymohan
1 Replies
3. Shell Programming and Scripting
please
help me for this
"divide the file into multiple files containing no more than 50 lines each and find the number of words of length less than 5 characters" (3 Replies)
Discussion started by: annapurna konga
3 Replies
4. Shell Programming and Scripting
What should be the Shell script that counts a number of unique word contained in a file and print them in alphabetical order line by line? (7 Replies)
Discussion started by: proactiveaditya
7 Replies
5. UNIX for Dummies Questions & Answers
If i have a file sample.txt with more than 10 columns and 11th column as following data. would it be possible to get the distinct counts of values in single shot,Thank you.
Y
Y
N
N
N
P
P
o
Expected Result:
Value count
Y 2
N 3
P 2 (2 Replies)
Discussion started by: Ariean
2 Replies
6. Shell Programming and Scripting
I need a Shell script which take two inputs which are
1) main directory where it has to search and
2) pattern to search within main directory all files (.c and .h files)
It has to print number of pattern found in main directory & each sub directory.
main dir --> Total pattern found = 5
|... (3 Replies)
Discussion started by: vivignesh
3 Replies
7. UNIX for Dummies Questions & Answers
Hi !
input:
A|B|C|D
A|F|C|E
A|B|I|C
A|T|I|B
As the title of the thread says, I would need to get:
1|3|2|4
I tried different variants of this command, but I don't manage to obtain what I need:
gawk 'BEGIN{FS=OFS="|"}{for(i=1; i<=NF; i++) a++} END {for (b in a) print b}' input
... (2 Replies)
Discussion started by: beca123456
2 Replies
8. Shell Programming and Scripting
I want to sort a file with a list of words, in order of most occuring words to least occurring words as well as alphabetically.
ex:
file1:
cat 3
cat 7
cat 1
dog 3
dog 5
dog 9
dog 1
ape 4
ape 2
I want the outcome to be:
file1.sorted:
dog 1 (12 Replies)
Discussion started by: castrojc
12 Replies
9. Shell Programming and Scripting
Hi ,
I need to count the number of errors associated with the two words occurring in the file. It's about counting the occurrences of the word "error" for where is the word "index.js". As such the command should look like. Please kindly help. I was trying: grep "error" log.txt | wc -l (1 Reply)
Discussion started by: jmarx
1 Replies
10. Shell Programming and Scripting
The awk below is supposed to count all the matching $5 strings and count how many $7 values is less than 20. I don't think I need the portion in bold as I do not need any decimal point or format, but can not seem to get the correct counts. Thank you :).
file
chr5 77316500 77316628 ... (6 Replies)
Discussion started by: cmccabe
6 Replies
LEARN ABOUT REDHAT
ldap_sort_strcasecmp
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)