Hi everyone,
I am working on a small language translation program, and am stuck trying to use awk.
I have so far created three files:
1. main menu file
2. lookup file with awk, which is called from main menu file
3. language file containing english, french and serbian words, like:
sea mer more
water eau voda
I want user to enter english word, and french equivalent should appear on the screen. I want to store user input - like 'car' into variable, which is then used as search term. Once line containing 'car' is found, I want to display word in second column ($2), which is french equivalent.
This is my code:
echo "Enter the word in english:"
read string
echo "Same word in french is:"
awk $1=$string '{print $2}' lang_words.txt
echo
echo "press any key to continue"
read key
I get ^ parse error when trying to run this, and have tried all combinations on this theme, but to no avail. Can somebody help me get over this, as I have no other ideas.
Ivan K. Grant
I am working on a small language translation program, and am stuck trying to use awk.
I have so far created three files:
1. main menu file
2. lookup file with awk, which is called from main menu file
3. language file containing english, french and serbian words, like:
sea mer more
water eau voda
I want user to enter english word, and french equivalent should appear on the screen. I want to store user input - like 'car' into variable, which is then used as search term. Once line containing 'car' is found, I want to display word in second column ($2), which is french equivalent.
This is my code:
echo "Enter the word in english:"
read string
echo "Same word in french is:"
awk $1=$string '{print $2}' lang_words.txt
echo
echo "press any key to continue"
read key
I get ^ parse error when trying to run this, and have tried all combinations on this theme, but to no avail. Can somebody help me get over this, as I have no other ideas.
Ivan K. Grant