Solved

Need help sorting and combining 2 files

Posted on 2008-10-17
7
242 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
Comment Utility
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
Comment Utility
#!/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
Comment Utility
Ok that works but how do I pipe the output to a file?
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 84

Expert Comment

by:ozo
Comment Utility
 > file
0
 

Author Comment

by:kkatula
Comment Utility
#!/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
Comment Utility
./vit3.sh > almost.txt
0
 

Author Closing Comment

by:kkatula
Comment Utility
Brilliant!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

762 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now