In my simple database, it contains text of like, example, soldiers.
Name:Rank:Gender:Age:Years of Service Tom Corporal:Recruit:Male:19:2 Nicole Sergeant:Corporal:Female:30:10 Daniel Recruit:Sergeant:Male:40:19 And my script goes like this:
echo "Enter name: " read name echo "Enter rank: " read rank echo "Enter gender: " read gender echo "Enter age: " read age echo "Enter Years of service: " read years grep $name database.txt If I enter "Corporal" into name, the output will show
Tom Corporal:Recruit:Male:19:2 Nicole Sergeant:Corporal:Female:30:10 because the string matches under the section name and rank. How do i use delimiter : to categories the search, so if i enter my conditions under rank, it will search just the rank category and not everything else.
Thanks in advance.
And do up my question instead of down voting.