I have a datafile as below.
datafile
Sterling|Man City|England
Kane|Tottenham|England
Ronaldo|Man Utd|Portugal
Ederson|Man City|Brazil
If I want to find a player that has a "Man City" and "England" trait I would write a command as such in the interpreter.
grep "Man City" datafile | grep "England"
output: Sterling|Man City|England
Like this, I want to make a shell script that receives multiple(more than 1) arguments that finds a line which has all the arguments in it. It would receive input as arg1 arg2 arg3... and return all the data lines that has the arguments. The program would run like this.
$ ./find ManCity England
output: Sterling|Man City|England
But I have absolutely no idea how to implement the command that does multiple grep for each argument. Can you use a for loop and implement in a code that does something like this?
grep arg1 datafile | grep arg2 | grep arg3 ...
Also, if there is a better way to find a data line that has all the arguments(AND of the arguments) can you please show me how?