1

I need to use two variables entered by the user to able the match two files.

Actors.txt:

James Bond - A
The Rock - A
John Cena - B

Interests.txt:

James Bond - Shooting
John Cena - Wrestling
The Rock - Wrestling 

So the user should enter the interest followed by the Group and then i should display the matched Names

Code :

#!/bin/bash
echo "Enter Group"
read groupid *// example : A*
echo "Enter Interest"
read int *// example : Wrestling*
echo "Result :"
nawk -F "-" '/int/ {print $1}' Interests.txt | grep "$(nawk -F "-" '/groupid/ {print $1}' Actors.txt)" 

Expected output : The Rock

jww
  • 97,681
  • 90
  • 411
  • 885
PetaBytes
  • 11
  • 2

0 Answers0