![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| awk help required to group output and print a part of group line and original line | rajan_san | Shell Programming and Scripting | 5 | 10-27-2008 09:16 AM |
| compare data line by line from a file | loperam | Shell Programming and Scripting | 1 | 10-22-2008 04:52 PM |
| Append Output to another file in Perl | Raynon | Shell Programming and Scripting | 7 | 09-03-2008 04:29 AM |
| How to grep / zgrep to output ONLY the matching filename and line number? | vvaidyan | UNIX for Dummies Questions & Answers | 3 | 03-12-2008 05:33 PM |
| Need to identify the line containing @ in between the line of a file | b.paramanatti | UNIX for Dummies Questions & Answers | 4 | 11-04-2007 10:50 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Identify matching data in a file and output to original line, in perl
Hi,
I haven't done this for awhile, and further, I've never done it in perl so I appreciate any help you can give me. I have a file of lines, each with 5 data points that look like this: AB,N,ALLIANCEBERNSTEIN HLDNG L.P,AB,N ALD,N,ALLIED CAPITAL CORPORATION,ALD,N AFC,N,ALLIED CAPITAL CORPORATION,ALD,N Let's call it: a,b,c,d,e Every time a == d and b == e, I want to then search every other line in the file and find where a == d(newline) and a == e(newline). Whenever this is the case, I want to append the a,b data from the newline to the original line such that it reads: a,b,c,d,e,a(newline),b(newline). Using the data above, we would output something like this: AB,N,ALLIANCEBERNSTEIN HLDNG L.P,AB,N ALD,N,ALLIED CAPITAL CORPORATION,ALD,N,AFC,N AFC,N,ALLIED CAPITAL CORPORATION,ALD,N I'm also not sure how many total matches there might be in the file so I could end up with ~100 matching lines for any original line such that the final result for the original line would look like: a,b,c,d,e,a(newline0),b(newline0)...,a(newline100),b(newline100) Does that make sense? |
| Bookmarks |
| Tags |
| concatenate, matching data, perl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|