Create xml with bash need array in an array or alternate method

Need some help and pointers I am trying to do something that is likely a bad idea but I am not sure the alternate method. I am creating an xml file called input.apProgram I have a script and it fills it out just as I need. I am grabbing files names from a directory and filling out an array with it as there may be a bunch of files in the future. I have to strip the file path and extension and use it again to fill out 4 other sections in the script. I have tried using an array inside an array and I either get nothing or too much due to the array in an array. Here is the script.

#!/bin/bash
set -x
# this will grab files from the designated folder and create an xml
# which later runs in the background


ls "C:/opti/o0904/cnhbensonol1/parts2do/"*.* > tmp	#folder with cad files
newpath=$(cygpath -w "C:/opti/O0904/cnhbensonol1/parts2do/"*.*) # needs paths with \
rm tmp 		#it works
echo "$newpath" > tmp

file_in="tmp"
file_out="input.apProgram"
#arr=("Mild Steel" "AutoPOL")    #material and machine, this could change


# static text formatted

header='<?xml version="1.0" encoding="utf-8"?>
<Program version="1.2">
    <Input>
		<Name>OPTI</Name>
    </Input>
	<Parts>'

echo "$header" > $file_out
while IFS=$',' read -r -a arry;	#this array fills in the cad file for the directory. 
do
  echo '        <Part>
            <Input>' >> $file_out
  echo '                <File>'${arry[0]}'</File>' >> $file_out
  echo '	            <OnlyUnfolder>true</OnlyUnfolder>' >> $file_out
  echo '                <SaveSettings>
  	                <NCFile>
	                <Save>true</Save>
	                <Directory>C:\opti\o0904\cnhbensonol1\OUTPUT\NC FILES</Directory>' >> $file_out
cat tmp | rev | cut -d"\\" -f1 | rev | cut -f1 -d "." > out.txt 

    line=`cat C:/opti/O0904/cnhbensonol1/out.txt`
	while IFS= read -r line; do
echo '	                <File>"$line"</File>
	                </NCFile>
	                <Graphics>
	                    <Save>true</Save>
		                <Directory>C:\opti\o0904\cnhbensonol1\OUTPUT\NC FILES</Directory>
     			        <File>'$line'</File>
	                </Graphics>
	                <FlatPatternDXF>
		                <Save>true</Save>
		                <Directory>C:\opti\o0904\cnhbensonol1\OUTPUT\DXF FILES</Directory>
		                <DXFSetting>OPTI</DXFSetting>
  			        <File>'$line'</File>
	                </FlatPatternDXF>
	                <AutoPOLFile>
		                <Save>true</Save>
		                <Directory>C:\opti\o0904\cnhbensonol1\OUTPUT\POLP FILES</Directory>
       	                <File>'$line'</File>
	                </AutoPOLFile>
	                <ProcessDocumentation>
	    	            <Save>true</Save>
		                <Directory>C:\opti\o0904\cnhbensonol1\OUTPUT\PDF FILES</Directory>
		                <File>'$line'</File>
	                </ProcessDocumentation>
                </SaveSettings>
	        </Input>' >> $file_out
echo '	    </Part>' >> $file_out
	done < $line
done < $file_in

printf "%s\n" "header"
echo '    </Parts>
</Program>' >> $file_out
rm out.txt 
rm tmp

currently the second array does not work as I would like and is giving an error ambiguous redirect.

Output should be like so. I apologize for the length of this but It is necessary.

<?xml version="1.0" encoding="utf-8"?>
<Program version="1.2">
    <Input>
		<Name>Demo</Name>
    </Input>
	<Parts>
        <Part>
            <Input>
                <File>C:\opti\O0904\cnhbensonol1\DXF FILES\20038100.SLDPRT</File>
                <Machine>AutoPOL</Machine>
  		        <OnlyUnfolder>true</OnlyUnfolder>
                <SaveSettings>
  	                <NCFile>
	                <Save>true</Save>
	                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\NC FILES</Directory>
	                <File>20038100</File>
	                </NCFile>
	                <Graphics>
	                    <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\NC FILES</Directory>
     			        <File>20038100</File>
	                </Graphics>
	                <FlatPatternDXF>
		                <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\DXF FILES</Directory>
		                <DXFSetting>OPTI</DXFSetting>
  			        <File>20038100</File>
	                </FlatPatternDXF>
	                <AutoPOLFile>
		                <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\POLP FILES</Directory>
       	                <File>20038100</File>
	                </AutoPOLFile>
	                <ProcessDocumentation>
	    	            <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\PDF FILES</Directory>
		                <File>20038100</File>
	                </ProcessDocumentation>
                </SaveSettings>
	        </Input>
	    </Part>
        <Part>
            <Input>
                <File>C:\opti\O0904\cnhbensonol1\DXF FILES\20136210.SLDPRT</File>
                <Machine>AutoPOL</Machine>
  		        <OnlyUnfolder>true</OnlyUnfolder>
                <SaveSettings>
  	                <NCFile>
	                <Save>true</Save>
	                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\NC FILES</Directory>
	                <File>20136210</File>
	                </NCFile>
	                <Graphics>
	                    <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\NC FILES</Directory>
     			        <File>20136210</File>
	                </Graphics>
	                <FlatPatternDXF>
		                <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\DXF FILES</Directory>
		                <DXFSetting>OPTI</DXFSetting>
  			        <File>20136210</File>
	                </FlatPatternDXF>
	                <AutoPOLFile>
		                <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\POLP FILES</Directory>
       	                <File>20136210</File>
	                </AutoPOLFile>
	                <ProcessDocumentation>
	    	            <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\PDF FILES</Directory>
		                <File>20136210</File>
	                </ProcessDocumentation>
                </SaveSettings>
	        </Input>
	    </Part>
        <Part>
            <Input>
                <File>C:\opti\O0904\cnhbensonol1\DXF FILES\4_2-1.igs</File>
                <Material>Mild Steel</Material>
                <Machine>AutoPOL</Machine>
  		        <OnlyUnfolder>true</OnlyUnfolder>
                <SaveSettings>
  	                <NCFile>
	                <Save>true</Save>
	                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\NC FILES</Directory>
	                <File>4_2-1</File>
	                </NCFile>
	                <Graphics>
	                    <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\NC FILES</Directory>
     			        <File>4_2-1</File>
	                </Graphics>
	                <FlatPatternDXF>
		                <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\DXF FILES</Directory>
		                <DXFSetting>OPTI</DXFSetting>
  			        <File>4_2-1</File>
	                </FlatPatternDXF>
	                <AutoPOLFile>
		                <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\POLP FILES</Directory>
       	                <File>4_2-1</File>
	                </AutoPOLFile>
	                <ProcessDocumentation>
	    	            <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\PDF FILES</Directory>
		                <File>4_2-1</File>
	                </ProcessDocumentation>
                </SaveSettings>
	        </Input>
	    </Part>
        <Part>
            <Input>
                <File>C:\opti\O0904\cnhbensonol1\DXF FILES\KC900.igs</File>
                <Material>Mild Steel</Material>
                <Machine>AutoPOL</Machine>
  		        <OnlyUnfolder>true</OnlyUnfolder>
                <SaveSettings>
  	                <NCFile>
	                <Save>true</Save>
	                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\NC FILES</Directory>
	                <File>KC900</File>
	                </NCFile>
	                <Graphics>
	                    <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\NC FILES</Directory>
     			        <File>KC900</File>
	                </Graphics>
	                <FlatPatternDXF>
		                <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\DXF FILES</Directory>
		                <DXFSetting>OPTI</DXFSetting>
  			        <File>KC900</File>
	                </FlatPatternDXF>
	                <AutoPOLFile>
		                <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\POLP FILES</Directory>
       	                <File>KC900</File>
	                </AutoPOLFile>
	                <ProcessDocumentation>
	    	            <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\PDF FILES</Directory>
		                <File>KC900</File>
	                </ProcessDocumentation>
                </SaveSettings>
	        </Input>
	    </Part>
        <Part>
            <Input>
                <File>C:\opti\O0904\cnhbensonol1\DXF FILES\MetalSheet_Pusher.step</File>
                <Material>Mild Steel</Material>
                <Machine>AutoPOL</Machine>
  		        <OnlyUnfolder>true</OnlyUnfolder>
                <SaveSettings>
  	                <NCFile>
	                <Save>true</Save>
	                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\NC FILES</Directory>
	                <File>MetalSheet_Pusher</File>
	                </NCFile>
	                <Graphics>
	                    <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\NC FILES</Directory>
     			        <File>MetalSheet_Pusher</File>
	                </Graphics>
	                <FlatPatternDXF>
		                <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\DXF FILES</Directory>
		                <DXFSetting>OPTI</DXFSetting>
  			        <File>MetalSheet_Pusher</File>
	                </FlatPatternDXF>
	                <AutoPOLFile>
		                <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\POLP FILES</Directory>
       	                <File>MetalSheet_Pusher</File>
	                </AutoPOLFile>
	                <ProcessDocumentation>
	    	            <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\PDF FILES</Directory>
		                <File>MetalSheet_Pusher</File>
	                </ProcessDocumentation>
                </SaveSettings>
	        </Input>
	    </Part>
        <Part>
            <Input>
                <File>C:\opti\O0904\cnhbensonol1\DXF FILES\Sheet Metal Part 8.igs</File>
                <Material>Mild Steel</Material>
                <Machine>AutoPOL</Machine>
  		        <OnlyUnfolder>true</OnlyUnfolder>
                <SaveSettings>
  	                <NCFile>
	                <Save>true</Save>
	                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\NC FILES</Directory>
	                <File>Sheet Metal Part 8</File>
	                </NCFile>
	                <Graphics>
	                    <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\NC FILES</Directory>
     			        <File>Sheet Metal Part 8</File>
	                </Graphics>
	                <FlatPatternDXF>
		                <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\DXF FILES</Directory>
		                <DXFSetting>OPTI</DXFSetting>
  			        <File>Sheet Metal Part 8</File>
	                </FlatPatternDXF>
	                <AutoPOLFile>
		                <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\POLP FILES</Directory>
       	                <File>Sheet Metal Part 8</File>
	                </AutoPOLFile>
	                <ProcessDocumentation>
	    	            <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\PDF FILES</Directory>
		                <File>Sheet Metal Part 8</File>
	                </ProcessDocumentation>
                </SaveSettings>
	        </Input>
	    </Part>
		<Part>
            <Input>
                <File>C:\opti\O0904\cnhbensonol1\DXF FILES\91780562_A.igs</File>
                <Material>Mild Steel</Material>
                <Machine>AutoPOL</Machine>
  		        <OnlyUnfolder>true</OnlyUnfolder>
                <SaveSettings>
  	                <NCFile>
	                <Save>true</Save>
	                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\NC FILES</Directory>
	                <File>91780562_A</File>
	                </NCFile>
	                <Graphics>
	                    <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\NC FILES</Directory>
     			        <File>91780562_A</File>
	                </Graphics>
	                <FlatPatternDXF>
		                <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\DXF FILES</Directory>
		                <DXFSetting>OPTI</DXFSetting>
  			        <File>91780562_A</File>
	                </FlatPatternDXF>
	                <AutoPOLFile>
		                <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\POLP FILES</Directory>
       	                <File>91780562_A</File>
	                </AutoPOLFile>
	                <ProcessDocumentation>
	    	            <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\PDF FILES</Directory>
		                <File>91780562_A</File>
	                </ProcessDocumentation>
                </SaveSettings>
	        </Input>
	    </Part>
		<Part>
            <Input>
                <File>C:\opti\O0904\cnhbensonol1\DXF FILES\91813583_A.igs</File>
                <Material>Mild Steel</Material>
                <Machine>AutoPOL</Machine>
  		        <OnlyUnfolder>true</OnlyUnfolder>
                <SaveSettings>
  	                <NCFile>
	                <Save>true</Save>
	                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\NC FILES</Directory>
	                <File>91813583_A</File>
	                </NCFile>
	                <Graphics>
	                    <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\NC FILES</Directory>
     			        <File>91813583_A</File>
	                </Graphics>
	                <FlatPatternDXF>
		                <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\DXF FILES</Directory>
		                <DXFSetting>OPTI</DXFSetting>
  			        <File>91813583_A</File>
	                </FlatPatternDXF>
	                <AutoPOLFile>
		                <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\POLP FILES</Directory>
       	                <File>91813583_A</File>
	                </AutoPOLFile>
	                <ProcessDocumentation>
	    	            <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\PDF FILES</Directory>
		                <File>91813583_A</File>
	                </ProcessDocumentation>
                </SaveSettings>
	        </Input>
	    </Part>
    </Parts>
</Program>

The input file is cad files of undetermined number and can end in .igs. example
image

Problem: expand value of variables. You try it, but not to do it.
Understanding difference between ' and " in the command line.

VAR=string
echo 'Variable value is $VAR  and ...'
# echo 
# Variable value is $VAR  and ...
# not 
# Variable value is string  and ...

# but this work, expand value of 
echo "Variable value is $VAR and ..."

If you have " in your constant string, then you need remove special meaning of " to the char ".

Method1:

echo 'Variable value is '$VAR' and ...'
# or
echo "Variable value is $VAR and .."
# if you need echo ", then take of " special meaning
echo "Variable value is \"$VAR\" and .."

In your case I like to use HERE template. It's so nice to make dynamic templates. End TAG have to be col 1 in the line.

Methdod2:

# in this example used with cat. HERE is redirect from stdin, usable with any commands which support stdin.
cat <<TAG
Variable value is "$VAR" and  ...
Today is $(date)
<Element>$VAR</Element>
   <Child attr="$VAR2">Some</Child>
TAG

echo "So nice"

TAG you can define as you like it: EOT, EOF, XML, HTML, TEMPLATE, ...

Why you cat file to the variable? Why not just:
done < "C:/opti/O0904/cnhbensonol1/out.txt"

Or why first to the variable and then to file, why not directly cmd stdout redirect to the file?
cygpath -w "C:/opti/O0904/cnhbensonol1/parts2do/"*.* > tmp
And then just

while read line
do 
   ...
done < tmp

please,
use copy/paste rather than screenshot/photos especially when its input data.
show the directory tree you are using as input

pass your script through the shellcheck utility (there's an online version if not available via cygwin) and address any relevant issues its raises.

take a step back and look at the code - most of it repeating and think about how to condense those into a single block then iterate over that with input

for example your 'hard coded ...'

  	                <NCFile>
	                <Save>true</Save>
	                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\NC FILES</Directory>
	                <File>20038100</File>
	                </NCFile>
	                <Graphics>
	                    <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\NC FILES</Directory>
     			        <File>20038100</File>
	                </Graphics>
	                <FlatPatternDXF>
		                <Save>true</Save>
		                <Directory>C:\opti\O0904\cnhbensonol1\OUTPUT\DXF FILES</Directory>
		                <DXFSetting>OPTI</DXFSetting>
  			        <File>20038100</File>
...

could be condensed into ( an example for illustration )

for CADfile in NCFile Graphics FlatPatternDXF ... 
do
  for DIRECTORIES in "${DIRECTORIES}"
  do
    for FILE in "${FILES}"
    do
       <"${CADfile}"x>
       <Save>"${TrueorFalse}"</Save>
       <Directory>"${DIRECTORY}"</Directory>
       <File>"${FILE}"}
       </"${CADfile}">
    done
  done
done

further 'simplification' might be possible if you can populate each set of elements into aligned arrays , and a simple loop with indexing into each array element to populate

(example - for illustration purposes)

#
# obviously the population of each of the Arrays needs writing ... 
# and each array needs to have the same number of entries and they be aligned 
# with the other array elements
# perhaps putting each of the processes needed to populate the arrays in
# separate functions, which facilitates modifying/adding entries and 
# keeps the clean and (potentially) simpler to maintain.
#

buildCadArray

buildDirsArray

buildFilesArray

for (( index=0; index < "${#CADfileArray[*]} ; index++ ))
do  
        <"${CADfileArray[index]}"x>
           <Save>"${TrueorFalse}"</Save>
              <Directory>"${DIRSArray[index]}"</Directory>
              <File>"${FILESArray[index]}"}
        </"${CADfileArray[index]}">
        ...
done
...

I am looking at this from another way. What about taking 2 variables such as
p=(cat tmp) # this contains the cad directory mentioned earlier.
line=(cat tmp | rev | cut -d"\" -f1 | rev | cut -f1 -d ".")
then using a loop inserting these in the places I need them?
while IFS= read -r p && IFS= read -r line <$3
do
echo ' <Part>
<Input>' >> $file_out
echo ' <File>$p</File>' >> $file_out
echo ' <File>$line</File>
done < $tmp 3< $file_in

much condensed of course. I can see the contents of $p and $line but it does not fill in when echoed.

Not a computer atm, but if you have variables enclosed in single quotes they will not be expanded , they need to be in double quotes.
it's probably best to use the printf function rather
than echo

Format
printf "%s...." "$p" >> "$file_out"

there's plenty of examples online

I don't understand the assignment here.
Apparently you look for the technique to read from two input files.
The following reads lines from both files in parallel:

while IFS= read -r p && IFS= read -r line <&3
do
  ...
done < $tmp 3< $file_in

When the loop starts, both files after the done are opened for reading, and descriptors 0 (default input, stdin) and 3 are associated.
The loop forms a code block.
Within the block one can read lines from both descriptors.
Just read reads from descriptor 0 , read var <&3 reads from descrptor 3.
When the loop block is left, the files are automatically closed.
A demonstration:

# a { code block } with two input files
{
echo "line 1 from passwd"
read line
echo "$line"
echo "line 1 from group"
read line <&3
echo "$line"
echo "line 2 from group"
read line <&3
echo "$line"
echo "line 2 from passwd"
read line
echo "$line"
} < /etc/passwd 3< /etc/group
# end of block, files are closed

I have it working with this. Thanks for the response. I was close just not quite there. I am creating 2 variables and putting them in the script at different places. There is more filler of the same type in the middle so I didn't include it.

p=$(cat tmp)
line=$(cat tmp | rev | cut -d"\\" -f1 | rev | cut -f1 -d "." > out.txt)
while IFS= read -r p && IFS= read -r line <&3 # fill in cad dir and supporting docs
do
echo ' <Part>
<Input>' >> $file_out
echo ' <File>'$p'</File>' >> $file_out
echo ' <OnlyUnfolder>true</OnlyUnfolder>' >> $file_out
echo ' <SaveSettings>
<NCFile>
<Save>true</Save>
<Directory>C:\opti\o0904\cnhbensonol1\OUTPUT\NC FILES</Directory>' >> $file_out
echo ' <File>'$line'</File>
done < tmp 3< out.txt

First of all, you do not need the variables from

p=$(cat tmp)
line=$(cat tmp | rev | cut -d"\\" -f1 | rev | cut -f1 -d "." > out.txt)

You only need the out.txt

cat tmp | rev | cut -d"\\" -f1 | rev | cut -f1 -d "." > out.txt

tmp contains the same info but it has the complete file path which I needed for this task. Out is the same file without the path and extension.

hi @fletching , can you confirm ...

that you have a working solution ?
if so, this thread can be closed ?

PS: it would be good if you post your completed code (with sample inputs and sample results) , sharing solutions benefits all the community.

thks

In your case, if you process the tmp file line by line, you can each time construct the second variable from the first variable.

while IFS= read -r pathname
do
# construct the short name
# chop from the left till the rightmost backslash
  shortname=${pathname##*\\}
# chop from the right till the dot
  shortname=${shortname%.*}
# make the output
  echo ' <Part>
<Input>
 <File>'"$pathname"'</File>
 <File>'"$shortname"'</File>'
done < $tmp >> $file_out

The sample also uses one echo of a multi-lined string, and redirects the loop block to the output file descriptor 1 (default output, stdout).

The shell simply concatenates 'string' "string" 'string'
A $var is only substituted in "string"

This is the section where the script is used and is working. I admit that The version @MadeInGermany suggested above would likely work but I don't want to rewrite it at this point unless it might run more efficiently? Included a file that shows the output.

p=$(cat tmp)
 line=$(cat tmp | rev | cut -d"\\" -f1 | rev | cut -f1 -d "." > out.txt)


 while IFS= read -r p && IFS= read -r line <&3        # fill in cad dir and supporting docs
 do
   echo '        <Part>
             <Input>' >> $file_out
   echo '                <File>'$p'</File>' >> $file_out
   echo '               <OnlyUnfolder>true</OnlyUnfolder>' >> $file_out
   echo '                <SaveSettings>
                    <NCFile>
                    <Save>true</Save>
                    <Directory>C:\opti\o0904\cnhbensonol1\OUTPUT\NC FILES</Directory>' >> $file_out
 echo '                 <File>'$line'</File>
                    </NCFile>
                    <Graphics>
                        <Save>true</Save>
                        <Directory>C:\opti\o0904\cnhbensonol1\OUTPUT\NC FILES</Directory>
                        <File>'$line'</File>
                    </Graphics>
                    <FlatPatternDXF>
                        <Save>true</Save>
                        <Directory>C:\opti\o0904\cnhbensonol1\OUTPUT\DXF FILES</Directory>
                        <DXFSetting>OPTI</DXFSetting>
                    <File>'$line'</File>
                    </FlatPatternDXF>
                    <AutoPOLFile>
                        <Save>true</Save>
                        <Directory>C:\opti\o0904\cnhbensonol1\OUTPUT\POLP FILES</Directory>
                            <File>'$line'</File>
                    </AutoPOLFile>
                    <ProcessDocumentation>
                        <Save>true</Save>
                        <Directory>C:\opti\o0904\cnhbensonol1\OUTPUT\PDF FILES</Directory>
                        <File>'$line'</File>
                    </ProcessDocumentation>
                 </SaveSettings>
            </Input>' >> $file_out
 echo '     </Part>' >> $file_out
 done < tmp 3< out.txt

input.apProgram (12.0 KB)

@fletching,
pls use Code tags instead of iCode tags when posting code/data "blocks".
You can hover over the icons in the post editor to get the popups distinguishing the two.

I've edited your post for now...

It uses less resources, yes.
Please at least delete the useless
p=$(cat tmp)
from your version, as I told you before.

is the leading cat needed ?

line=$(cat tmp | rev .... )

can it be further reduced to ...

line=$( rev tmp | ... )

I am just trying to make sure I get the correct file. I will try it both ways and see. Thanks again.