Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • But where do you specify that its only Stef for which you want to extract records. I've edited the post to include what I have but I don't know how to include the if statement in there. Commented Sep 15, 2021 at 9:43
  • Sorry I edited again Commented Sep 15, 2021 at 9:44
  • How about this? awk 'NR==FNR{A[$1];next}$2 in A' file2.txt file1.txt | grep "Stef" Commented Sep 15, 2021 at 9:49
  • Yes both of the solutions work. Thank you! Commented Sep 15, 2021 at 11:23
  • Just in case you missed: | grep "Stef" will filter all the lines do not contains Stef | grep "^Stef" will filter all the lines do not start with Stef Commented Sep 15, 2021 at 11:32