mardi 3 mai 2016

I need to compare a list of patterns specified in a file to another file and report only the matching part of column containing pattern

I need to compare a list of patterns specified in a file to another file and report only the matching part of column containing pattern and one other column using linux

Below is an example:

file 1 shown below contains following names to be searched in file2;

Laura

Carloline

Chan

File to be searched - file2:

Name Title Salary

George Research fellow 48000

Vanesse, Laura , Robert Graduate student 20000

Patrick, Simon Data Analyst 58000

Caroline Administrative assistant 52000

Allison, Treacey, Chan Research Technician 60000

Below is the required output(name column containing only matching entries and salary column alone) :

Name Salary

Laura 20000

Caroline 52000

Chan 60000

I want to perform this task using linux commands. Can this be done using linux grep/awk command?

Aucun commentaire:

Enregistrer un commentaire