Im having issues with my shell script for school. There is a syntax error but I don't understand whats the issue. its on line 25, but it seems fine to me. I tried going through lecture notes but they don't seem to help. The script is supposed to pull a directory of XML files that are the elements of the periodic table, Write a shell script that will read all the .xml files in data-shell/data/elements directory of the data archive data.zip Download data.zipand create a file "Summary.txt" containing a summary table of the element data.
The summary table should contain 5 columns: "Name" = , "Abbreviation" = , "Weight" = , "Number" = , "Liquid Range" = - . it doesn't want to print the result, so here I am. If anyone can solve this issue, it would be greatly appreciated! enter image description here
the script:
#!/usr/bin/bash
yourfilenames=`ls ./*.xml`
echo -e "Name\tAbbreviation\tWeight\tNumber\tLiquid Range"
for eachfile in $yourfilenames
do
# here fetching out the values of mentioned variables
name=($(grep -oP '(?<=element-name>)[^<]+' "$eachfile"))
symbol=($(grep -oP '(?<=symbol>)[^<]+' "$eachfile"))
at_weight=($(grep -oP '(?<=atomic-weight>)[^<]+' "$eachfile"))
at_number=($(grep -oP '(?<=atomic-number>)[^<]+' "$eachfile"))
boiling_pt=($(grep -oP '(?<=boiling-point>)[^<]+' "$eachfile"))
melting_pt=($(grep -oP '(?<=melting-point>)[^<]+' "$eachfile"))
# doing a little bit of mathematical operation for finding out the liquid range of the element
liquid_range=$((boiling_pt - melting_pt))
# printing out the values of the variables in a tabular format
echo -e "$name\t$symbol\t\t$at_weight\t$at_number\t$liquid_range"
done