Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Need help sorting and combining 2 files

Posted on 2008-10-17
7
Medium Priority
?
272 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
  • 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 85

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
Independent Software Vendors: 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 85

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 85

Accepted Solution

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

Author Closing Comment

by:kkatula
ID: 31507170
Brilliant!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Starting up a Project
Loops Section Overview
Suggested Courses

886 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