I have a file with a lot of addresses where I want to list unique addresses and the number of theirs occurrence.
I have this input file:
And I want something like this (order by number of occurrence):
I am thinking about using uniq combined with sort but I only want to uniq on the address and not the hole line
Thx in advance
Last edited by Scott; 11-12-2010 at 03:45 PM..
Reason: Code tags
Hi,
I need to find the number of occurrence of string in a file,
for ex:
>cat filename
abc
abc
def
ghi
ghi
ghi
ghi
abc
abc
>output would be
abc 4
def 1 (10 Replies)
Hi All,
is there a way to extract the line number of an occurrence using grep?
I know that with the -n option it prints out the line number as well.
I would like to assign the line number to a variable.
Thanks,
Sarah (5 Replies)
Hi all,
is there a simple way to obtain the line number of the i-th occurrence of a pattern?
I have
OCCURRENCE=`grep -io "${STRING_NAME}" ${1}-${8}${EXT}.out_bis| wc -l`
which tells me how many occurency I have. I would like to go through them and determine the line number and assign... (6 Replies)
Ok,
So I have a huge file that has over 12000 lines in it.
in this file, there are 589 occurrences of the string "use five-minute-interval" spread in various areas in the file.
How can i replace the the last 250 of the occurrences of "use five-minute-interval" with "use... (10 Replies)
Hi
I have the following file
ENST001 ENST002 4 4 4 88 9 9
ENST004 3 3 3 99 8 8
ENST009 ENST010 ENST006 8 8 8 77 8 8
Basically I want to count how many times ENST* is repeated in each line so the expected results is
2
1
3
Any suggestion please ? (4 Replies)
if there's a file containing:
money king money queen money cat money also money king
all those strings are on one line in the file.
how can i find out how many times "money king" shows up in the line?
egrep -c "money king" wont work. (7 Replies)
Hi,
I have a file which contained a set of numbers like
Col1 col2 col3 col4
1 sa 13 0
2 sb 14 0
3 sc 15 9
4 sd 16 -9
5 sd 20 -2
6 sd 20 4
Here in last column I need to count the zeros, positive values and negative values,
please help me to do that. (2 Replies)
My file contains like this on 10 th line
NM1*IL*1*
awk '/NM1/{print NR}' *.dat
output is 10
awk '/NM1*IL*1*/{print NR}' *.dat
output is Nothing
but im expecting 10 on second code as well . (4 Replies)
Hi all,
I am looking for to filter out based on 7th character and list the number of occurrence based on the 7th character if p , d , o or m
1. if 7th character is p , Output should be: p_hosts = N
2. if 7th character is d , Output should be: d_hosts = N
3. if 7th character is o , Output... (10 Replies)
Discussion started by: rveri
10 Replies
LEARN ABOUT OSF1
uniq
uniq(1) General Commands Manual uniq(1)NAME
uniq - Removes or lists repeated lines in a file
SYNOPSIS
Current Syntax
uniq [-cdu] [-f fields] [-s chars] [input-file [output-file]]
Obsolescent Syntax
uniq [-cdu] [-fields] [+chars] [input-file [output-file]]
The uniq command reads from the specified input_file, compares adjacent lines, removes the second and succeeding occurrences of a line, and
writes to standard output.
STANDARDS
Interfaces documented on this reference page conform to industry standards as follows:
uniq: XCU5.0
Refer to the standards(5) reference page for more information about industry standards and associated tags.
OPTIONS
Precedes each output line with a count of the number of times each line appears in the file. This option supersedes the -d and -u options.
Displays repeated lines only. Ignores the first fields fields on each input line when doing comparisons, where fields is a positive deci-
mal integer. A field is the maximal string matched by the basic regular expression:
[[:blank:]]*[^[:blank:]]*
If the fields argument specifies more fields than appear on an input line, a null string is used for comparisons. Ignores the spec-
ified number of characters when doing comparisons. The chars argument is a positive decimal integer.
If specified with the -f option, the first chars characters after the first fields fields are ignored. If the chars argument speci-
fies more characters than remain on an input line, uniq uses a null string for comparison. Displays unique lines only. Equivalent
to -f fields. (Obsolescent) Equivalent to -s chars. (Obsolescent)
OPERANDS
A pathname for the input file.
If this operand is omitted or specified as -, then standard input is read. A pathname for the output file.
If this operand is omitted, then standard output is written.
DESCRIPTION
The input_file and output_file arguments must be different files. If the input_file operand is not specified, or if it is -, uniq uses
standard input.
Repeated lines must be on consecutive lines to be found. You can arrange them with the sort command before processing.
EXAMPLES
To delete repeated lines in the following file called fruit and save it to a file named newfruit, enter: uniq fruit newfruit
The file fruit contains the following lines:
apples apples bananas cherries cherries peaches pears
The file newfruit contains the following lines:
apples bananas cherries peaches pears
EXIT STATUS
The following exit values are returned: Successful completion. An error occurred.
ENVIRONMENT VARIABLES
The following environment variables affect the execution of uniq: Provides a default value for the internationalization variables that are
unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization vari-
ables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value,
overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes
of text data as characters (for example, single-byte as opposed to multibyte characters in arguments). Determines the locale for the for-
mat and contents of diagnostic messages written to standard error. Determines the location of message catalogues for the processing of
LC_MESSAGES.
SEE ALSO
Commands: comm(1), sort(1)
Standards: standards(5)uniq(1)