so I have a bash script that is supposed to print peoples names and their scores from a text file
The text input file is as follows
Ted 86
Anthony 70
Mark 95
Kyle 65
David 75
This is my code
#! /bin/bash
inputfile="$1"
if [[ !(-f "$1") ]]; then
echo "$1 must be a file"
exit 1
else
echo "$1 is a file"
fi
names=()
scores=()
while read line
do
lineArray=($line)
names+=(${lineArray[0]})
scores+=(${lineArray[1]})
done < $inputfile
echo "${names[@]} ${scores[@]}"
This is the output
score is a file
Ted Anthony Mark Kyle David 86 70 95 65 75
My issue is, I need the output to be displayed in the same way as it appears in the input text file and I don't know how to use a loop to do it. Thank you