![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Combining two files | hemangjani | Shell Programming and Scripting | 7 | 06-13-2007 11:32 PM |
| Combining Two Files | bat711 | Shell Programming and Scripting | 3 | 10-05-2005 02:26 PM |
| Combining files | Enda Martin | UNIX for Dummies Questions & Answers | 2 | 07-20-2001 11:31 AM |
| combining files | apalex | UNIX for Dummies Questions & Answers | 3 | 06-19-2001 10:49 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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, |
|
||||
|
Correction
Sorry, let me try that again.
I have 2 files with many lines. 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, Thanks, |
|
||||
|
Code:
file1
ul22222 Jon Smith
ug88888 Mildred Apple
file2
CN=VXX,CN=ug88888,OU=America,OU=State,OU=VXX,
awk '{
if (NR==FNR)
x[$1] = $0
else {
FS=","
split($2,a,"=")
if (x[a[2]])
print x[a[2]], $0
}
}' file1 file2
Last edited by shamrock; 10-17-2008 at 09:22 PM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|