Operating System - HP-UX
1753778 Members
8095 Online
108799 Solutions
New Discussion юеВ

Scripting question related to joining two files with a string added....

 
SOLVED
Go to solution
Vijaya Kumar_3
Respected Contributor

Scripting question related to joining two files with a string added....

Hello,

I have two files named "abc" and "xyz". Their contents are here:

File "abc":

object1
object2
object3

File "xyz":

table1
table2
table3

My requirement is to create an command output like this.

delete from 'object1' on 'table1';
delete from 'object2' on 'table2';
delete from 'object3' on 'table3';

Right now, I played with "vi" and able to create the new file.... However, is it a better sed or awk one liner for this? or even perl?

I will assign the points.

Regards
Vijay Chinnasamy

Known is a drop, unknown is ocean - visit me at http://vijay.theunixplace.com
2 REPLIES 2
Bill Hassell
Honored Contributor
Solution

Re: Scripting question related to joining two files with a string added....

The easiest way is:

paste abc xyz

Then format the results into awk or other filters such as this:

$ paste abc xyz | while read OBJ TBL
> do
> echo "delete from '$OBJ' on '$TBL'"
> done
delete from 'object1' on 'table1'
delete from 'object2' on 'table2'
delete from 'object3' on 'table3'


Bill Hassell, sysadmin
Vijaya Kumar_3
Respected Contributor

Re: Scripting question related to joining two files with a string added....

Works like a champ. Thank you.
Known is a drop, unknown is ocean - visit me at http://vijay.theunixplace.com