I am very new to the shell scripting world. I have done some research on this but seems not working so far.
What I am trying to do is I have two txt files. I want to search all the strings from file A in File B, and display all the lines from file B that has the strings in it.
So far, I only have this(please don’t laugh)…
#!bin/sh
for LINE in 'cat $1'
do
grep '$LINE' $2
done
I guess I am trying to make it dynamic, so I can execute something like this
./script.ksh fileA.txt fileB.txt
Any suggestion would be appreciated and thanks so much!
You were very close to your goal, but there are some minor errors in your code.
This should work:
Here’s an example:
fileA.txt:
fileB.txt:
Output: