Sponsored Content
Top Forums Shell Programming and Scripting remove duplicate lines using awk Post 302492303 by homeboy on Monday 31st of January 2011 01:30:13 AM
Old 01-31-2011
x is a array and it's initialized to 0.the index of x is $0,if $0 is first time meet,then plus 1 to the value of x[$0],x[$0] now is 1.As ++ here is "suffix ++",0 is returned and then be added.So !x[$0] is true,the $0 is printed by default.if $0 appears more than once,! x[$0] will be false so won't print $0.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove Duplicate Lines in File

I am doing KSH script to remove duplicate lines in a file. Let say the file has format below. FileA 1253-6856 3101-4011 1827-1356 1822-1157 1822-1157 1000-1410 1000-1410 1822-1231 1822-1231 3101-4011 1822-1157 1822-1231 and I want to simply it with no duplicate line as file... (5 Replies)
Discussion started by: Teh Tiack Ein
5 Replies

2. Shell Programming and Scripting

how to remove duplicate lines

I have following file content (3 fields each line): 23 888 10.0.0.1 dfh 787 10.0.0.2 dssf dgfas 10.0.0.3 dsgas dg 10.0.0.4 df dasa 10.0.0.5 df dag 10.0.0.5 dfd dfdas 10.0.0.5 dfd dfd 10.0.0.6 daf nfd 10.0.0.6 ... as can be seen, that the third field is ip address and sorted. but... (3 Replies)
Discussion started by: fredao
3 Replies

3. UNIX for Dummies Questions & Answers

Remove Duplicate lines from File

I have a log file "logreport" that contains several lines as seen below: 04:20:00 /usr/lib/snmp/snmpdx: Agent snmpd appeared dead but responded to ping 06:38:08 /usr/lib/snmp/snmpdx: Agent snmpd appeared dead but responded to ping 07:11:05 /usr/lib/snmp/snmpdx: Agent snmpd appeared dead but... (18 Replies)
Discussion started by: Nysif Steve
18 Replies

4. Shell Programming and Scripting

Command to remove duplicate lines with perl,sed,awk

Input: hello hello hello hello monkey donkey hello hello drink dance drink Output should be: hello hello monkey donkey drink dance (9 Replies)
Discussion started by: cola
9 Replies

5. Shell Programming and Scripting

Remove duplicate lines

Hi, I have a huge file which is about 50GB. There are many lines. The file format likes 21 rs885550 0 9887804 C C T C C C C C C C 21 rs210498 0 9928860 0 0 C C 0 0 0 0 0 0 21 rs303304 0 9941889 A A A A A A A A A A 22 rs303304 0 9941890 0 A A A A A A A A A The question is that there are a few... (4 Replies)
Discussion started by: zhshqzyc
4 Replies

6. Shell Programming and Scripting

[uniq + awk?] How to remove duplicate blocks of lines in files?

Hello again, I am wanting to remove all duplicate blocks of XML code in a file. This is an example: input: <string-array name="threeItems"> <item>item1</item> <item>item2</item> <item>item3</item> </string-array> <string-array name="twoItems"> <item>item1</item> <item>item2</item>... (19 Replies)
Discussion started by: raidzero
19 Replies

7. Shell Programming and Scripting

Cant get awk 1liner to remove duplicate lines from Delimited file, get "event not found" error..help

Hi, I am on a Solaris8 machine If someone can help me with adjusting this awk 1 liner (turning it into a real awkscript) to get by this "event not found error" ...or Present Perl solution code that works for Perl5.8 in the csh shell ...that would be great. ****************** ... (3 Replies)
Discussion started by: andy b
3 Replies

8. UNIX for Dummies Questions & Answers

Remove Duplicate Lines

Hi I need this output. Thanks. Input: TAZ YET FOO FOO VAK TAZ BAR Output: YET VAK BAR (10 Replies)
Discussion started by: tara123
10 Replies

9. Shell Programming and Scripting

How to remove duplicate lines?

Hi All, I am storing the result in the variable result_text using the below code. result_text=$(printf "$result_text\t\n$name") The result_text is having the below text. Which is having duplicate lines. file and time for the interval 03:30 - 03:45 file and time for the interval 03:30 - 03:45 ... (4 Replies)
Discussion started by: nalu
4 Replies

10. Shell Programming and Scripting

How to put the command to remove duplicate lines in my awk script?

I create a CGI in bash/html. My awk script looks like : echo "<table>" for fn in /var/www/cgi-bin/LPAR_MAP/*; do echo "<td>" echo "<PRE>" awk -F',|;' -v test="$test" ' NR==1 { split(FILENAME ,a,""); } $0 ~ test { if(!header++){ ... (12 Replies)
Discussion started by: Tim2424
12 Replies
xpc_array_create(3)					   BSD Library Functions Manual 				       xpc_array_create(3)

NAME
xpc_array_create -- creation and management of XPC arrays SYNOPSIS
#include <xpc/xpc.h> xpc_object_t xpc_array_create(const xpc_object_t *objects, size_t count); void xpc_array_set_value(xpc_object_t array, size_t index, xpc_object_t value); void xpc_array_append_value(xpc_object_t array, xpc_object_t value); xpc_object_t xpc_array_get_value(xpc_object_t array, size_t index); size_t xpc_array_get_count(xpc_object_t array); bool xpc_array_apply(xpc_object_t array, xpc_array_applier_t applier); void xpc_array_set_bool(xpc_object_t array, size_t index, bool value); void xpc_array_set_int64(xpc_object_t array, size_t index, int64_t value); void xpc_array_set_uint64(xpc_object_t array, size_t index, uint64_t value); void xpc_array_set_double(xpc_object_t array, size_t index, double value); void xpc_array_set_date(xpc_object_t array, size_t index, int64_t value); void xpc_array_set_data(xpc_object_t array, size_t index, const void *bytes, size_t length); void xpc_array_set_string(xpc_object_t array, size_t index, const char *value); void xpc_array_set_uuid(xpc_object_t array, size_t index, const uuid_t value); void xpc_array_set_fd(xpc_object_t array, size_t index, int value); void xpc_array_set_connection(xpc_object_t array, size_t index, xpc_connection_t value); bool xpc_array_get_bool(xpc_object_t array, size_t index); int64_t xpc_array_get_int64(xpc_object_t array, size_t index); uint64_t xpc_array_get_uint64(xpc_object_t array, size_t index); double xpc_array_get_double(xpc_object_t array, size_t index); int64_t xpc_array_get_date(xpc_object_t array, size_t index); const void * xpc_array_get_data(xpc_object_t array, size_t index, size_t *length); const uint8_t * xpc_array_get_uuid(xpc_object_t array, size_t index); const char * xpc_array_get_string(xpc_object_t array, size_t index); int xpc_array_dup_fd(xpc_object_t array, size_t index); ARRAYS
XPC arrays are collections of XPC objects ordered by index. The index is zero-based. XPC arrays are contiguous, and values must exist at all indexes between zero and the greatest index of the array. A hole in the array can be simulated by using a null object as returned by xpc_null_create(3). CREATION
The xpc_array_create() function returns a newly created array. The caller may optionally provide objects, a C array of XPC object references, to initialize the array. The count is used to specify the size of the C array. If objects is NULL, then count must be zero. If count speci- fies more elements than are actually present in values or if values is NULL and count is non-zero, the behavior is undefined. GETTING AND SETTING VALUES
The xpc_array_append_value() function may be used to append a value to the end of an array. This operation increases the count of the values in the array by one. The value of a specific index in the array may be set using the xpc_array_set_value() function. The value must be non-NULL, and the index must already exist (i.e. less than the count provided at creation or extended through previous append operations). The value at a specific index of an array may be retrieved using the xpc_array_get_value() function. The result of getting a non-existing index (i.e. one that was not specified at creation or through a previous append operation) in undefined. PRIMITIVE GET AND SET FUNCTIONS
Various functions exist for retrieving primitive C and operating system types directly from an array without the need for an intermediate boxed object. See xpc_object(3) for more information. The special XPC_ARRAY_APPEND constant may be used to append a value to the end of the array instead of operating on a specific index. ITERATION
The xpc_array_apply() function may be used to iterate the index and value pairs of an array using an applier callback block. The callback block is invoked for each pair and must return a bool indicating whether the iteration should continue (true if it should continue, false if it should not). The xpc_array_apply() function will return true if the applier block was called and returned true for all pairs, or false if it was not (i.e. the applier returned false during the iteration, which may have caused iteration to stop early). SEE ALSO
xpc_object(3), xpc_objects(3), xpc_dictionary_create(3) Darwin 1 July, 2011 Darwin
All times are GMT -4. The time now is 10:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy