Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I do this?(take from first file and then put in second file)

Status
Not open for further replies.

sheffy

Technical User
Jan 30, 2003
1
US
TYhis is what I want to do:
My first file has the following kind of entries
Ther are randomly distributed throughout the file.
Of course the file contains other entries besides the !! entries.

!!LDAP_PRIMARY_HOST_SSI!!
!!LDAP_PRIMARY_SSI!!

and so on... T


Now my second file is pretty similar expect it doesn't have any bang bang(!!).
So it has:
LDAP_PRIMARY_HOST_SSI

LDAP_PRIMARY_SSI



Now this is what I need to do. I need to find out all entries which have bang bang in front of the word and behind the word and then find the corresponding entries in the second file which do not have this !!. Then I need to take thes eentries without bang bang and put bang bang in front and back just like I have it in the first file. So my second file will become
!!LDAP_PRIMARY_HOST_SSI!!
!!LDAP_PRIMARY_SSI!!

How can I do this in awk...
 
f1 = bangfile
f2 = no-bangfile


awk 'BEGIN{
FS="!"
while ((getline < &quot;f1&quot;) > 0) { arr[ $3] = 1}
}
{
if( arr[$1] == 1) print &quot;!!&quot; $1 &quot;!!&quot;

}' f2

regards Gregor Gregor.Weertman@mailcity.com
 
How do I compare individual fields(essentially an ascii character) from two different files and write the result at the same field on a third file .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top