write a bash script which generate a table using data from ar.tar.gz

to fill the table take data only from 0h0w/$i/results/plotfile0.gpdat files (first and third real value).

table should have 3 columns, first with name of subdirectory $i, the rest with corresponding real numbers.

if there is problem with automatic identification of names for subdirectories one add them by hand (but automatisation is welcome).

as an input the script shoult take the name of the main catalog ("0h0w") and a name of an output table file.

 #!/ bin / bash

 echo " Enter target directory name : "
 read target_name

 echo " Enter output file name : "
 read output_name

 if [ -f " $output_name " ]; then
 truncate -s 0 $output_name
 fi

 for file in $target_name /*
 do
 IFS =’/’ read -a fileArray <<< " $file "

 while IFS =’’ read -r line ; do
     IFS =’ ’ read -a lineArray <<< " $line "
         echo "${ fileArray [1]} & ${ lineArray [1]} & ${ lineArray [2]} \\\\ "
        >> $output_name
     done < $file / results / plotfile0 . gpdat
 done

Niestety nie mogę dojść do końcowego wyniku, powyżej zagadnienia, proszę o pomoc!