merging similar lines


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting merging similar lines
# 1  
Old 05-04-2009
merging similar lines

Greetings, I have been trying to merge the following lines:
Code:
Sat. May 9 8:00 PM
Sat. May 9 8:00 PM CW
Sat. May 9 8:00 PM CW Cursed
Sat. May 9 9:00 PM
Sat. May 9 9:00 PM CW
Sat. May 9 9:00 PM CW Sanctuary
Sat. May 16 8:00 PM
Sat. May 16 8:00 PM CW
Sat. May 16 8:00 PM CW Sanctuary
Sat. May 16 9:00 PM
Sat. May 16 9:00 PM CW
Sat. May 16 9:00 PM CW Fever
Sat. May 16 9:00 PM CW Fever #1.21

however when i run the following:
Code:
uniq -u -i -f6

I still get this:
Code:
Sat. May 9 8:00 PM CW Cursed
Sat. May 9 9:00 PM CW Sanctuary
Sat. May 16 8:00 PM CW Sanctuary
Sat. May 16 9:00 PM CW Fever
Sat. May 16 9:00 PM CW Fever #1.21

why doesn't the second and third (the sanctuary lines) merge?

Also -- is there a way to do this with a perl script with the added requirement that if there is something like #1.21 then it keeps that line over the one that does not have it?

thanks!!
# 2  
Old 05-05-2009
-f6 means ignore the first six fields - start with the field that has Cursed in it.
Instead of telling what you did not get, please give us EXACTLY what you expect as output.
# 3  
Old 05-05-2009
I expected to get the following:

Code:
Sat. May 9 8:00 PM CW Cursed
Sat. May 9 9:00 PM CW Sanctuary
Sat. May 16 9:00 PM CW Fever
Sat. May 16 9:00 PM CW Fever #1.21

Basically, there was an extra Sanctuary line.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Getting similar lines in two files

Hi, I need to compare the /etc/passwd files from 2 servers, and extract the users that are similar in these two files. I sorted the 2 files based on the user IDs (UID) (3rd column). I first sorted the files using the username (1st column), however when I use comm to compare the files there is no... (1 Reply)
Discussion started by: anaigini45
1 Replies

2. Shell Programming and Scripting

Merging multiple lines to columns with awk, while inserting commas for missing lines

Hello all, I have a large csv file where there are four types of rows I need to merge into one row per person, where there is a column for each possible code / type of row, even if that code/row isn't there for that person. In the csv, a person may be listed from one to four times... (9 Replies)
Discussion started by: RalphNY
9 Replies

3. Shell Programming and Scripting

Count lines with similar tokens

I have 2 files, and I wish to count number of lines with this characteristic: if any token at line x in file1, is similar to a token at line x in file2. Here's an example: file1: ab, abc ef fg file2: ab cd ef gh In this case I wish to get 3. Note that token of file1 are... (3 Replies)
Discussion started by: Viernes
3 Replies

4. Shell Programming and Scripting

Merging two columns from two files with similar names into a loop

I have two files like this: fileA.net A B C fileA.dat 1 2 3 and I want the output output_expected A 1 B 2 C 3 I know that the easier way is to do a paste fileA.net fileA.dat, but the problem is that I have 10,000 couple of files (fileB.net with fileB.dat; fileC.net with... (3 Replies)
Discussion started by: valente
3 Replies

5. Shell Programming and Scripting

merging two .txt files by alternating x lines from file 1 and y lines from file2

Hi everyone, I have two files (A and B) and want to combine them to one by always taking 10 rows from file A and subsequently 6 lines from file B. This process shall be repeated 40 times (file A = 400 lines; file B = 240 lines). Does anybody have an idea how to do that using perl, awk or sed?... (6 Replies)
Discussion started by: ink_LE
6 Replies

6. Shell Programming and Scripting

Maximum Value of similar lines

Hi, Pretty new to scripting sed awk etc. I'm trying to speed up calculations of disk space allocation. I've extracted the data i want and cleaned it up but i cant figure out the final step. I need to discover a Maximum value of 1 field where the value of another field is the same using awk so... (4 Replies)
Discussion started by: imarcs
4 Replies

7. Shell Programming and Scripting

Counting similar lines

Hi, I have a little problem with counting lines. I know similar topics from this forum, but they don't resolve my problem. I have file with lines like this: 2009-05-25 16:55:32,143 some text some regular expressions ect. 2009-05-25 16:55:32,144 some text. 2009-05-28 18:15:12,148 some... (4 Replies)
Discussion started by: marcinnnn
4 Replies

8. Shell Programming and Scripting

merging similar columns in a single line file

Hi Guys. I have tried the commands sort and join. But I couldn't able to to find the command for joining in a single line based on keys.My example inputs and outputs are like the following. Help would be appreciated.:D Input file a1tabXXXXXXX a2tabXXXXXXX a6tabYYYYYYYYY a71tabXXXXXXX... (7 Replies)
Discussion started by: repinementer
7 Replies

9. Shell Programming and Scripting

Urgent help needed on merging lines with similar words

Hi everyone, I need help with a merging problem. Basically, I have a file with several lines (in this example 9 lines) such as: Amie, Jay, Sasha, Rob, Kay Mia, Frank Jay, Nancy, Cecil Paul, Ked, Nancy, 17, Fred 14, 16, 18, 20 9, 11 12, Frank 18, Peter, 62 Nancy, 27 A delimiter is... (3 Replies)
Discussion started by: awb221
3 Replies

10. Shell Programming and Scripting

Deleting the similar lines

Dear Friends myself Avinash working in bash shell The problem goes like this I have a file called work.txt assume that first colum=mac address second colum= IP third colum = port number ---------------------------------------- 00:12:23:34 192.168.50.1 2 00:12:23:35 192.168.50.1 5... (2 Replies)
Discussion started by: avi.skynet
2 Replies
Login or Register to Ask a Question