Eliminate redundant data pairs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Eliminate redundant data pairs
# 1  
Old 12-30-2009
Bug Eliminate redundant data pairs

Hello Experts:

I appeal to you to see if you can help me with a small problem. I have a .log file where there is data in two columns (separated by a space).

The file is thus:

Code:
0.0 3
0.0 6
0.0 6
0.0 6
0.0 7
0.0 7
0.0 7
0.0 7
0.0 11
0.0 11
0.0 11
0.0 11
0.0 11
0.1 17
0.1 17
0.1 17
0.1 17
0.1 17
0.1 17
0.1 17
0.1 17
0.1 17
0.1 17
0.1 17
0.1 17
0.1 17
0.1 17
0.1 17
0.1 17
0.1 17
0.1 17
0.1 17
0.1 17
0.2 17
0.2 17
0.2 17
0.2 17
0.2 17
0.2 17
0.2 17
0.2 17
0.2 17
0.2 17

The overall length is close to the 20000 rows. I was wondering how eliminate redundant data pairs, for example, from the list above, there are many:

Code:
0.1 17
0.1 17
0.1 17
0.1 17
0.1 17
0.1 17
0.1 17

And the truth is that I need only 1 of those pairs of values. I hope you can help me. Of course, I'll be very grateful.

Cordial Greetings friends.

Last edited by Flamex; 12-30-2009 at 12:40 PM.. Reason: Please use code tags!
# 2  
Old 12-30-2009
Hello.

Per our forum rules, all posts must be in English.

We do provide translation services for posts from English to a number of languages as a benefit to users. However, posts must be in English.

Please repost in English.

Thank you for your cooperation.

The UNIX and Linux Forums.
# 3  
Old 12-30-2009
Tools Message, in Spanish

Please forgive if any translation is mistaken - simply a way to let someone know in their language of our message to them.

Hola.
Por nuestro foro gobierna, todos postes deben ser en inglés.
Proporcionamos traducción servicios para postes de inglés a varios idiomas como un beneficio a usuarios.
Sin embargo, los postes deben ser en inglés.
Por favor repost en inglés.
Gracias por su cooperación.
El UNIX y Foros de Linux.
# 4  
Old 12-30-2009
Eliminating redundant data that is already sorted is easy with 'uniq'

Code:
uniq inputfile outputfile

# 5  
Old 12-30-2009
Tools Be aware of original file data

If original data is not sorted, the uniq command will give strange results. You may need to sort the data prior to a uniq command.
I manually placed a few of the last entries at the beginning of the file, and see the results:
Code:
>uniq uniqsample.txt
0.2 17
0.0 3
0.0 6
0.0 7
0.0 11
0.1 17
0.2 17

# 6  
Old 12-30-2009
A frequent asked question, if the file is not sorted:
Code:
awk '!a[$0]++' file

# 7  
Old 12-30-2009
thank you very much!

Now I have my vectors as I needed.

thanks a lot
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Eliminate or ignore asterisks in data when parsing

I have data file that has this in it: data.txt ......... ......... PPJ97**2017PPJ97**2017-03-21-13.35.15.887208********************START ERROR LOGGING****************** PPJ97**2017-03-21-13.35.15.887208** PROMPT APPLICATION ERROR ** PPJ97**2017-03-21-13.35.15.887208** IN TIMESTAMP |... (1 Reply)
Discussion started by: SkySmart
1 Replies

2. Shell Programming and Scripting

Extracting data between two tag pairs

In a huge log file (43MB, 43k lines) I am trying to extract data between two tag pairs on same line and export it to a file so I can pull it into Excel for a report. One Pair is <Text>data I need</Text> Other pair follows on same line and is <TimeStamp>more data I need</TimeStamp> I would need... (2 Replies)
Discussion started by: NanookArctic
2 Replies

3. Shell Programming and Scripting

Reduce redundant file

Dear All, I have to reduce the redundancy of a file that is like this: a b 0 a c 0 a f 1 b a 1 b a 0 b c 1 d f 0 g h 1 f d 1 Basically, this file describe a network with relative nodes and edges. The nodes are the different letters and the edges are represented by the numbers (in... (7 Replies)
Discussion started by: giuliangiuseppe
7 Replies

4. Shell Programming and Scripting

Edit a script in 2 redundant servers at once

Hi All, We have a redundant server system and every time we need any change in any particular script then we need to do it individually in each of the server. I want to create a shell script such that if i make changes in primary server and run the script then it should update the changes to ... (0 Replies)
Discussion started by: crimemastergogo
0 Replies

5. Shell Programming and Scripting

Find redundant text in a file

I want to find which pattern or strings have occurred more than one time so that I can remove unnecessary redundancy. For example: If I have the sentence: A quick brown brown fox jumps jumps jumps over the lazy dog in a file, then I want to know that 1. the word "brown" has... (7 Replies)
Discussion started by: hbar
7 Replies

6. UNIX for Dummies Questions & Answers

Deleting all rows that contain redundant information

My input file looks like this: 1 rs4040617 0.08356 1 rs4040617 0.06799 1 rs2977612 0.07948 1 rs2977612 0.07882 1 rs2977612 0.07783 1 rs2977612 0.08142 1 rs2977612 0.07716 1 rs2977612 0.08356 1 rs2977612 0.06799 1 rs2980300 0.08356 1 rs2980300 0.08142 I want to delete all rows that... (1 Reply)
Discussion started by: evelibertine
1 Replies

7. Filesystems, Disks and Memory

ZFS Raidz not redundant?

My ZFS on debian media server just died in a power outage, the zpool status shows this: NAME STATE READ WRITE CKSUM tank UNAVAIL 0 0 0 insufficient replicas raidz1 UNAVAIL 0 0 0 corrupted data sda ONLINE 0 0 0 sdb ONLINE 0 0 0 sdf ONLINE 0 0 0 sdh ONLINE 0 0 0 sdi ONLINE 0 0 0 sdk ONLINE 0... (2 Replies)
Discussion started by: mastersarg
2 Replies

8. Shell Programming and Scripting

Eliminate unwanted data

Hi, I am stuck on writing a script that reads a file, retains wanted data but discards unwanted data from a CSV file. This is a sample of my table {not the actual data) ID Color tel_num Name color2 color3 abcdef green 5551212 jj88 red blue acbdfe yellow... (5 Replies)
Discussion started by: t524ube
5 Replies

9. UNIX for Dummies Questions & Answers

Question is redundant but please advice

I am really really new to Unix. I'm lost with so many books around for different shell. I'm thinking of taking a course on Operating Systems but it contains a lot of Unix programming I think. For example, someone was talking about a "which" command. But I wasn't able to figure out what it does...... (10 Replies)
Discussion started by: Legend986
10 Replies

10. Shell Programming and Scripting

to check redundant file names

hi i have a very simple problem iam moving files from download to archive folder but before such a transfer want to make sure no two file of same are present in my download directory how to check for redundant file names i thought of using WC but it counts inside the file (lines and... (5 Replies)
Discussion started by: maverick
5 Replies
Login or Register to Ask a Question