Using file content as input for awk search patterns
HI,
I'm having trouble constructing a shell script using the awk command to solve my problem. Problem: I have two csv-files which look something like the following A small file (file1.csv) Code:
$ head -2 file1.csv Code:
$ head -3 file2.csv file1.csv contains information about a group of users file2.csv contains information about all users Does anyone know howto create a new file (file3.csv) containing a list of usernames and names of the persons listed in file1.csv like this? Code:
$ head -2 file3.csv Can anybody offer me some help? Thanks. |
paste file2.csv file1.csv | sed s/,/\ /g | awk '{print $1" "$5}'
|
Or you could just use awk:
Code:
awk -F, 'FNR == NR{names[$3]++;next}$2 in names' file1 file2 > file3 |
All times are GMT -5. The time now is 01:09 AM. |