Hallo all,
I try to create a bash script but till now without any positiv results.
The script should replace different variables in a text file with the right xml values
Look at the following xml file:
file.xml
===================================
<?xml version="1.0" encoding="UTF-8"?>
<Daten>
<export_date>2008-07-15 16:29:01</export_date>
<language>english</language>
temp.txt
===================================
All dates were exported at <export_date>
The text was translated in <language>
script.sh
===================================
#!/bin/bash
IFS=$'\n'
for i in `cat file.xml | sed 's/>/ /g' | awk '{print $1}' | sed 's/</ /g' | sed 's/ //g'`
do
for j in \`grep "$i" temp.txt | sed 's/.*<//g'| sed 's/>.*//g' \`
do
\#echo $j
for h in `cat temp.txt | sed -e "s/"$j"/$(cat file.xml | grep "$j" | sed 's/>/ /g' | sed 's/</ /g' | awk '{print $2}')/g" >> temp2 `
do
echo $h
done
done
done
The aim should be
All dates were exported at 2008-07-15 16:29:01
The text was translated in english.
Do you know how I could work on this?
thx