Originally posted by: Tim_at_Boeing
I am new at AIX/UNIX and need to build a set of output files based on a template file and a list of parameters. I've done this in other languages but not in UNIX. We are at AIX/UNIX Version 5.3.
I assume with a loop of some kind but I'm not sure how to do edits and output within loops.
Read record 1 from parameter.txt file. Store field2 and field3. Edit sample.sql file replacing the question marks with the vaule of field2. Then output the results into a new file called sample_one.sql (using value of field2) and quit sample.sql.
Read record 2 from parameter.txt file. Store field2 and field3. Edit sample.sql file replacing the question marks with the vaule of field2. Then output the results into a new file called sample_two.sql (using value of field2) and quit sample.sql.
Read record 3 from parameter.txt file. Store field2 and field3. Edit sample.sql file replacing the question marks with the vaule of field2. Then output the results into a new file called sample_eleven.sql (using value of field2) and quit sample.sql.
=== Template file ===
sample.sql
SELECT F1,F2,F3
FROM TABLE1
WHERE F1 = ?
=== Parameter file ===
parameter.txt
01~1~one~
02~2~two~
11~11~eleven~
=== Output files ===
sample_one.sql
SELECT F1,F2,F3
FROM TABLE1
WHERE F1 = 1
sample_two.sql
SELECT F1,F2,F3
FROM TABLE1
WHERE F1 = 2
sample_eleven.sql
SELECT F1,F2,F3
FROM TABLE1
WHERE F1 = 11
#AIX-Forum