I have a problem with the grep
command.
I have a file, called dictionary.txt, containing 2 columns of words, like
abc def
apple orange
hour minute
In my Bash script, having entered the word in the left column as an argument, I have to output the corresponding word on the right using the grep
command.
A requirement is to use a loop.
I created this script:
#!/bin/bash
parola=$1
for traduzione in $( sort dictionary.txt )
do
if [ $parola == $traduzione ]
then
grep $traduzione | cut -f 2 dictionary.txt
fi
done
This does not work as described above.