Supposedly this is my data:
Lord of The Ring:Johnny Dept:56.80:100:38
Three Little Pig:Andrew Lim:89.10:290:189
All About Ubuntu:Ubuntu Team:76.00:55:133
Catch Me If You Can:Mary Ann:23.60:6:2
Happy Day:Mary Ann:12.99:197:101
Harry Potter:J.K Rowling:23:32:421
jo:jojo:2000:120:293
the code:
function search_book
{
    echo "4) search_book"
    read -p "Title: " title
    read -p "Author: " author
    searchtitle=` grep -i "^$title:$author:*" BooksDB.txt | cut -d: -f 1 `
    searchauthor=` grep -i "^$title:$author:*" BooksDB.txt | cut -d: -f 2 `
    #Data does not compute to true if two variables are filled and exist if not typed fully
    if [[ $searchtitle == $title ]] || [[ $searchauthor == $author ]]
    then
    recordcount=`cat | grep -iE "*$title" BooksDB.txt | grep -iEc "$author" `
    echo "Found $recordcount records"
    echo 
    grep -iE "*$title" BooksDB.txt | grep -iE "$author" |\
        awk -F: 'BEGIN{print "Title:Author:Price:Available Copies:Sold Copies\n"}
        {print $1":"$2":$"$3":"$4":"$5}' | column -s ":" -t
    echo 
    else
    echo "No Books found."
    fi
}
Program's output:
4) search_book
Title: jo
Author: 
Found 2 records
Title             Author       Price   Available Copies  Sold Copies
Lord of The Ring  Johnny Dept  $56.80  100               38
jo                jojo         $2000   120               293
When my title is jo, only the second record is supposed to be the result but where and why does it made it such that it searches both title and author altogether?
Expected result:
4) search_book
Title: jo
Author: 
Found 2 records
Title             Author       Price   Available Copies  Sold Copies
jo                jojo         $2000   120               293
 
     
     
     
     
     
    