Solved

Need help sorting and combining 2 files

Posted on 2008-10-17
7
253 Views
Last Modified: 2013-11-13
I have 2 files with many lines.

File one example:
CN=VXX,CN=ug88888,OU=America,OU=State,OU=VXX,
File two example
ul22222 Jon Smith
ug8888 Mildred Apple
I need a routine that will take the ug88888 portion of the first file and pull out the corresponding full line in file two.  Then add the two together so the final output is
ug8888 Mildred Apple CN=VXX,CN=ug88888,OU=America,OU=State,OU=VXX,

Thanks,
0
Comment
Question by:kkatula
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 

Author Comment

by:kkatula
ID: 22741981
Let me try that again:

File one example:
CN=VXX,CN=ug8888,OU=America,OU=State,OU=VXX,
File two example
ul22222 Jon Smith
ug8888 Mildred Apple
I need a routine that will take the ug8888 portion of the first file and pull out the corresponding full line in file two.  Then add the two together so the final output is
ug8888 Mildred Apple CN=VXX,CN=ug8888,OU=America,OU=State,OU=VXX,
0
 
LVL 84

Expert Comment

by:ozo
ID: 22743358
#!/usr/bin/perl
open F2,"<filetwo" or die $!;
my %CN = map{(/((\w+)\s+.*)/)[1,0]}<F2>;
close F2;
open F1,"<fileone" or die $!;
print "@CN{/CN=(\w+)/g} $_"  while <F1>;
close F1;
0
 

Author Comment

by:kkatula
ID: 22743670
Ok that works but how do I pipe the output to a file?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 84

Expert Comment

by:ozo
ID: 22743714
 > file
0
 

Author Comment

by:kkatula
ID: 22743735
#!/usr/bin/perl
open F2,"<People_IN_VCE.csv" or die $!;
my %CN = map{(/((\w+)\s+.*)/)[1,0]}<F2>;
close F2;
open F1,"<file_c" or die $!;
print "@CN{/CN=(\w+)/g} $_"  while <F1>;>almost.txt
close F1;

gives this error:
syntax error at ./vit3.sh line 6, near ";>"
Execution of ./vit3.sh aborted due to compilation errors.
0
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 22743809
./vit3.sh > almost.txt
0
 

Author Closing Comment

by:kkatula
ID: 31507170
Brilliant!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
unable to put logic for reading multiple repo in a single file 4 69
ASP/VB email question 4 61
AvlTree-Node Data type 4 23
Error building VS2105 solution from repository 1 34
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question