I need to program a football league table with football round results in a text file of this format
abc 4 def 5 ghi 9 hef 10
where format is
[home team][home team points][guest team][guest team points]
And the program will accept five teams and have multiple text files to read. What I don't know is how to get the points of each correspond team. I have seen some solutions on parsing string with one whitespace and delimiter in this site. However, I need to read like this abc 4 def 5 and so on. Is there any solutions?
The following is the code at this moment. I just figuring out how to read correspond scores of a team. Thanks for your kindly help.
if [ $# -eq 0 ]; then
echo "No argument"
else
echo "The number of arguments : $#"
echo "The full list : $@"
myArray=("$@")
echo "${myArray[0]}"
arraylength=${#myArray[@]}
declare -p myArray
#loop for places entered
for ((i=0;i<${arraylength};i++));
do
#iterate on the files stored to find target
for matchfile in match*.txt;
do
declare file_content=$( cat "${matchfile}" )
#check whether a file has target lanaguage
if [[ " $file_content " =~ ${myArray[i]} ]] # please note the space before and after the file content
then
#awk -v a="$file_content" -v b="${myArray[i]}" 'BEGIN{print index(a,b)}'
#echo "${myArray[i]}"
#let j=j+1
echo "${myArray[i]} found in ${matchfile}: with a score ..."
fi
done
done
fi
exit