Shell Script to new file referring other files -


can please in writing shell script below requirement.

i have csv file shown below in comma separated format

a,b,c d,e,f 

there file in values written mentioned below:-

ramesh suresh 

with of above 2 files need construct new file.

<root> <env name="a" domain="b">     <component name="ramesh">         <machine name="c">ramesh</machine>     </component>     <component name="suresh">         <machine name="c">suresh</machine>     </component> </env> <env name="d" domain="e">     <component name="ramesh">         <machine name="f">ramesh</machine>     </component>     <component name="suresh">         <machine name="f">suresh</machine>     </component> </env> </root> 

try this;

#!/bin/bash echo "<root>"  while read csvline;     echo $csvline |    awk -f ',' '{print "<env name=\""$1 "\" domain=\"" $2"\">"}'     csvcol3=$(echo $csvline |awk -f ',' '{print $3}')       while read secondfileline;           echo -e '\t<component name="'$secondfileline'">'          echo -e '\t\t<machine name="'$csvcol3'">'$secondfileline'</machine>'          echo -e '\t</component>'       done < secondfile.txt    echo '</env>' done < file.csv echo "</root>" 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -