Paste... Awk... Perl... Bash... Stumped on this
I have two files (Asterisk)
File one:
[1234]
type=friend
username=1234
secret=1234
host=dynamic
context=admin
mailbox=1234@anywhere
callerid="Anywhere" <1234>
nat=no
File two:
1234 Somewhere
I need to ensure that entries in file_one match file_two...
Something similar to:
awk '/1234/{gsub(/Somewhere/, "Anywhere")};{print}' file_one #Note it has to check file_two for replacement values
Awk has to read columns 1 and 2 in file two, compare it to the entry in file one:
This is what I get:
[root@crashbox ]# awk '/1234@/{getline;print}' sip.conf
callerid="Anywhere" <1234>
extension=`awk '{print $1}' file_two` # get an extension
newname=`awk '{print $2}' file_two` # get the new name
oldvalue=`awk '/$extension@/{getline;print}'` # grep extension followed by an @ sign and print the next line
This is where I'm stuck at... Replacing... I need to make sure in file_one, if the value in the example Anywhere is not the same as it is in file_two (Somewhere), it needs to replace Anywhere to Somewhere.
Make sense?
Super uber props on the help on this one...
perl -e 'print $i=pack(c5,(40*2),sqrt(7600),(unpack(c,Q)-3+1+3+3-7),oct(104),10,oct(101));'
I have two files (Asterisk)
File one:
[1234]
type=friend
username=1234
secret=1234
host=dynamic
context=admin
mailbox=1234@anywhere
callerid="Anywhere" <1234>
nat=no
File two:
1234 Somewhere
I need to ensure that entries in file_one match file_two...
Something similar to:
awk '/1234/{gsub(/Somewhere/, "Anywhere")};{print}' file_one #Note it has to check file_two for replacement values
Awk has to read columns 1 and 2 in file two, compare it to the entry in file one:
This is what I get:
[root@crashbox ]# awk '/1234@/{getline;print}' sip.conf
callerid="Anywhere" <1234>
extension=`awk '{print $1}' file_two` # get an extension
newname=`awk '{print $2}' file_two` # get the new name
oldvalue=`awk '/$extension@/{getline;print}'` # grep extension followed by an @ sign and print the next line
This is where I'm stuck at... Replacing... I need to make sure in file_one, if the value in the example Anywhere is not the same as it is in file_two (Somewhere), it needs to replace Anywhere to Somewhere.
Make sense?
Super uber props on the help on this one...
perl -e 'print $i=pack(c5,(40*2),sqrt(7600),(unpack(c,Q)-3+1+3+3-7),oct(104),10,oct(101));'