Solved

Need help sorting and combining 2 files

Posted on 2008-10-17
7
252 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 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 
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
Control Number of Log Files -Perl 7 86
Adding a continue option in a script 9 53
Eclipse Java import and method not resolved 4 43
Create .bat File 16 22
This is an explanation of a simple data model to help parse a JSON feed
A short article about problems I had with the new location API and permissions in Marshmallow
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.

789 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