I have posted the same code for another question recently. I was helped with that but when trying to implement an If-Then statement, it returned erroneous results. So within this topic I will have 2 questions.
First Question: When performing a search within a file, how do you implement the search so uppercase or lower case has no basis on returning the desired record?
Second Question: In my If-Then statement no matter what I type it shows the else part of the If-Then Statement. For example, the name Smith is in the file, but no matter what I type "Smith" or "smith" yields the same result as "echo "Error: $last_name is not in file"".
Additionally: This has to be written in korn shell programming.
The code is as follows:
#Gather search parameter
read last_name
if grep -Fxq "$last_name" $1
then
while IFS=: read c1 c2 c3 c4 c5 c6 c7 rest ; do
case "$c1" in
"$last_name" )
echo -e "Last Name: $c1\nFirst Name: $c2\nCity: $c3\nState: $c4\nClass: $c5\nSemester Enrolled: $c6\nYear First Enrolled: $c7\n\n"
;;
esac
done < $1
else
echo "Error: $last_name is not in file"
fi
;;
Any insight into the coding of this would be much appreciated.
Aucun commentaire:
Enregistrer un commentaire