7

Searching for values in a file

view full story
linux-howto

http://www.unix.com – Hi guys. I'm trying to do a search on the fruit & brand inside Fruit.txt, and printing the result out in the following format: [fruit], [brand], $[price], [qty] I am able to do this via the following code: Code: awk -F: -vOFS=", " -vt="$Fruit:$Brand" '$0~t{$3="$"$3;print}' Fruit.txt However, I want to be able to search only one word anywhere on the string (case insensitive), and it will still be able to return me the results. Example as follows: Code: Enter fruit name: sour Enter brand: [null] Found 2 matches: Sour Grapes, Sunsh (HowTos)