Sponsored Content
Top Forums Shell Programming and Scripting Delete duplicate lines... with a twist! Post 302576068 by shamrock on Wednesday 23rd of November 2011 02:07:33 PM
Old 11-23-2011
Quote:
Originally Posted by shadowww
Sure, It is 5mb compilation of trivia questions. One question per row with * for separator from answer (file will be used by irc trivia bot). Aim is to weed out automatically as much duplicate questions as possible. There is sample in my first post but here is bigger chunk of file: sample trivia - Pastebin.com which also shows entries that get selected as duplicates and deleted with your code - these are the ones starting with "Algebra : "
Is * the only non alphanumeric character in the input file as that makes it easy...but is that really the case as your original post had others...so if you define it clearly a better awk solution can be given...
This User Gave Thanks to shamrock For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

delete semi-duplicate lines from file?

Ok here's what I'm trying to do. I need to get a listing of all the mountpoints on a system into a file, which is easy enough, just using something like "mount | awk '{print $1}'" However, on a couple of systems, they have some mount points looking like this: /stage /stand /usr /MFPIS... (2 Replies)
Discussion started by: paqman
2 Replies

2. UNIX for Dummies Questions & Answers

Delete duplicate lines and print to file

OK, I have read several things on how to do this, but can't make it work. I am writing this to a vi file then calling it as an awk script. So I need to search a file for duplicate lines, delete duplicate lines, then write the result to another file, say /home/accountant/files/docs/nodup ... (2 Replies)
Discussion started by: bfurlong
2 Replies

3. UNIX for Dummies Questions & Answers

How to delete or remove duplicate lines in a file

Hi please help me how to remove duplicate lines in any file. I have a file having huge number of lines. i want to remove selected lines in it. And also if there exists duplicate lines, I want to delete the rest & just keep one of them. Please help me with any unix commands or even fortran... (7 Replies)
Discussion started by: reva
7 Replies

4. UNIX for Dummies Questions & Answers

Delete lines with duplicate strings based on date

Hey all, a relative bash/script newbie trying solve a problem. I've got a text file with lots of lines that I've been able to clean up and format with awk/sed/cut, but now I'd like to remove the lines with duplicate usernames based on time stamp. Here's what the data looks like 2007-11-03... (3 Replies)
Discussion started by: mattv
3 Replies

5. UNIX for Dummies Questions & Answers

How to delete partial duplicate lines unix

hi :) I need to delete partial duplicate lines I have this in a file sihp8027,/opt/cf20,1980182 sihp8027,/opt/oracle/10gRelIIcd,155200016 sihp8027,/opt/oracle/10gRelIIcd,155200176 sihp8027,/var/opt/ERP,10376312 and need to leave it like this: sihp8027,/opt/cf20,1980182... (2 Replies)
Discussion started by: C|KiLLeR|S
2 Replies

6. UNIX for Advanced & Expert Users

In a huge file, Delete duplicate lines leaving unique lines

Hi All, I have a very huge file (4GB) which has duplicate lines. I want to delete duplicate lines leaving unique lines. Sort, uniq, awk '!x++' are not working as its running out of buffer space. I dont know if this works : I want to read each line of the File in a For Loop, and want to... (16 Replies)
Discussion started by: krishnix
16 Replies

7. Shell Programming and Scripting

Delete lines in file containing duplicate strings, keeping longer strings

The question is not as simple as the title... I have a file, it looks like this <string name="string1">RZ-LED</string> <string name="string2">2.0</string> <string name="string2">Version 2.0</string> <string name="string3">BP</string> I would like to check for duplicate entries of... (11 Replies)
Discussion started by: raidzero
11 Replies

8. Shell Programming and Scripting

Delete duplicate rows

Hi, This is a followup to my earlier post him mno klm 20 76 . + . klm_mango unix_00000001; alp fdc klm 123 456 . + . klm_mango unix_0000103; her tkr klm 415 439 . + . klm_mango unix_00001043; abc tvr klm 20 76 . + . klm_mango unix_00000001; abc def klm 83 84 . + . klm_mango... (5 Replies)
Discussion started by: jacobs.smith
5 Replies

9. Shell Programming and Scripting

Find duplicate values in specific column and delete all the duplicate values

Dear folks I have a map file of around 54K lines and some of the values in the second column have the same value and I want to find them and delete all of the same values. I looked over duplicate commands but my case is not to keep one of the duplicate values. I want to remove all of the same... (4 Replies)
Discussion started by: sajmar
4 Replies

10. UNIX for Beginners Questions & Answers

Delete duplicate like pattern lines

Hi I need to delete duplicate like pattern lines from a text file containing 2 duplicates only (one being subset of the other) using sed or awk preferably. Input: FM:Chicago:Development FM:Chicago:Development:Score SR:Cary:Testing:Testcases PM:Newyork:Scripting PM:Newyork:Scripting:Audit... (6 Replies)
Discussion started by: tech_frk
6 Replies
Frontier::RPC2(3)					User Contributed Perl Documentation					 Frontier::RPC2(3)

NAME
Frontier::RPC2 - encode/decode RPC2 format XML SYNOPSIS
use Frontier::RPC2; $coder = Frontier::RPC2->new; $xml_string = $coder->encode_call($method, @args); $xml_string = $coder->encode_response($result); $xml_string = $coder->encode_fault($code, $message); $call = $coder->decode($xml_string); $response_xml = $coder->serve($request_xml, $methods); $boolean_object = $coder->boolean($boolean); $date_time_object = $coder->date_time($date_time); $base64_object = $coder->base64($base64); $int_object = $coder->int(42); $float_object = $coder->float(3.14159); $string_object = $coder->string("Foo"); DESCRIPTION
Frontier::RPC2 encodes and decodes XML RPC calls. $coder = Frontier::RPC2->new( OPTIONS ) Create a new encoder/decoder. The following option is supported: encoding The XML encoding to be specified in the XML declaration of encoded RPC requests or responses. Decoded results may have a different encoding specified; XML::Parser will convert decoded data to UTF-8. The default encoding is none, which uses XML 1.0's default of UTF-8. For example: $server = Frontier::RPC2->new( 'encoding' => 'ISO-8859-1' ); use_objects If set to a non-zero value will convert incoming <i4>, <float>, and <string> values to objects instead of scalars. See int(), float(), and string() below for more details. $xml_string = $coder->encode_call($method, @args) `"encode_call"' converts a method name and it's arguments into an RPC2 `"methodCall"' element, returning the XML fragment. $xml_string = $coder->encode_response($result) `"encode_response"' converts the return value of a procedure into an RPC2 `"methodResponse"' element containing the result, returning the XML fragment. $xml_string = $coder->encode_fault($code, $message) `"encode_fault"' converts a fault code and message into an RPC2 `"methodResponse"' element containing a `"fault"' element, returning the XML fragment. $call = $coder->decode($xml_string) `"decode"' converts an XML string containing an RPC2 `"methodCall"' or `"methodResponse"' element into a hash containing three members, `"type"', `"value"', and `"method_name"'. `"type"' is one of `"call"', `"response"', or `"fault"'. `"value"' is array containing the parameters or result of the RPC. For a `"call"' type, `"value"' contains call's parameters and `"method_name"' contains the method being called. For a `"response"' type, the `"value"' array contains call's result. For a `"fault"' type, the `"value"' array contains a hash with the two members `"faultCode"' and `"faultMessage"'. $response_xml = $coder->serve($request_xml, $methods) `"serve"' decodes `$request_xml', looks up the called method name in the `$methods' hash and calls it, and then encodes and returns the response as XML. $boolean_object = $coder->boolean($boolean); $date_time_object = $coder->date_time($date_time); $base64_object = $coder->base64($base64); These methods create and return XML-RPC-specific datatypes that can be passed to the encoder. The decoder may also return these datatypes. The corresponding package names (for use with `"ref()"', for example) are `"Frontier::RPC2::Boolean"', `"Fron- tier::RPC2::DateTime::ISO8601"', and `"Frontier::RPC2::Base64"'. You can change and retrieve the value of boolean, date/time, and base64 data using the `"value"' method of those objects, i.e.: $boolean = $boolean_object->value; $boolean_object->value(1); $int_object = $coder->int(42); $float_object = $coder->float(3.14159); $string_object = $coder->string("Foo"); By default, you may pass ordinary Perl values (scalars) to be encoded. RPC2 automatically converts them to XML-RPC types if they look like an integer, float, or as a string. This assumption causes problems when you want to pass a string that looks like "0096", RPC2 will convert that to an <i4> because it looks like an integer. With these methods, you could now create a string object like this: $part_num = $coder->string("0096"); and be confident that it will be passed as an XML-RPC string. You can change and retrieve values from objects using value() as described above. SEE ALSO
perl(1), Frontier::Daemon(3), Frontier::Client(3) <http://www.scripting.com/frontier5/xml/code/rpc.html> AUTHOR
Ken MacLeod <ken@bitsko.slc.ut.us> perl v5.8.0 2003-01-27 Frontier::RPC2(3)
All times are GMT -4. The time now is 03:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy