Solved

Need help sorting and combining 2 files

Posted on 2008-10-17
7
246 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What is the meaning of mount pont? with respect to windows file server. 7 57
Python Assistance 7 73
listing all functions in JavaScript 19 178
Solaris 4.1.3 cloning and booting 13 72
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
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 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…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

920 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

16 Experts available now in Live!

Get 1:1 Help Now