0

I'm trying to write a bash script that will take user input and search my file for matches. And then format the output to new lines

This is what I have but I'm getting an error unexpected EOF while looking for matching `''

echo 'Enter a Keyword: '
read Keyword
awk -v Keyword="$Keyword" '/$0 ~ Keyword/ -F: '{ print " Name: "$1"\n","Phone: "$2"\n","Email: "$3" }' myfile
jkmar
  • 1
  • 1
    Number of `"` is odd. Remove last `"`. – Cyrus Oct 04 '21 at 04:43
  • 2
    The single quotes are weird to: You first have a `'/$0 ~ Keyword/ -F: '`, followed by a `{`, then a space, which terminates this argument. Fix your quotes first. Perhaps the error will disappear. – user1934428 Oct 04 '21 at 12:38
  • 1
    See also [how-do-i-use-shell-variables-in-an-awk-script](https://stackoverflow.com/questions/19075671/how-do-i-use-shell-variables-in-an-awk-script) and [how-do-i-find-the-text-that-matches-a-pattern](https://stackoverflow.com/questions/65621325/how-do-i-find-the-text-that-matches-a-pattern) and get the book Effective AWK Programming, 5th Edition, by Arnold Robbins. – Ed Morton Oct 04 '21 at 14:02

0 Answers0