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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a new file from two separate input files

Status
Not open for further replies.

kobewins

Programmer
Dec 1, 2005
57
US
I'm a newbie for the scripting, but I have a task need to be done. Here is my problem, please help.

I've got the following two input files. Input file_1 contains alot of IDs (11 digits), each in a separate line. In Input file_2, there is only one line.

What I what to is open Input file_1, loop through it, use each of the IDs to replace XXXXXXXXXXX in Input file_2 and generate a new output file.

Input file_1

111111111111
222222222222
333333333333
444444444444
555555555555
666666666666
777777777777
888888888888
999999999999


Input File_2

AM01999999999AM02FE34AM05D7XXXXXXXXXXXAM10F4over


Output file

AM01999999999AM02FE34AM05D7111111111111AM10F4over
AM01999999999AM02FE34AM05D7222222222222AM10F4over
AM01999999999AM02FE34AM05D7333333333333AM10F4over
AM01999999999AM02FE34AM05D7444444444444AM10F4over
AM01999999999AM02FE34AM05D7555555555555AM10F4over
AM01999999999AM02FE34AM05D7666666666666AM10F4over
AM01999999999AM02FE34AM05D7777777777777AM10F4over
AM01999999999AM02FE34AM05D7888888888888AM10F4over
AM01999999999AM02FE34AM05D7999999999999AM10F4over

--
Thanks

mike
 
And what have you tried so far ?
One way I see is a small awk program.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
sorry, here are my try before.

while read buf
do sed -e "/^1/s/XXXXXXXXXXX/$buf/g" Inputfile_2 >outputfile
done < inputfile_1

mike
 
while read buf
do sed "/s/XXXXXXXXXXX/$buf/" Inputfile_2
done < inputfile_1 > outputfile

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top