Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- air
- smell
- hand
- dude
- road
- cat
- air,4,21,01,13,3,2
- smell,21,4,2,5,6
- dude,1,31,42,1
- road,1,4,2,1,4
- cat,1,5,6,3,1
- hand,1,4,2,1,6
- mouse,1,3,5,6,2
- air,4,21,01,13,3,2
- smell,21,4,2,5,6
- hand,1,4,2,1,6
- dude,1,31,42,1
- road,1,4,2,1,4
- cat,1,5,6,3,1
- awk -F, 'FNR==NR {a[$1]; next}; $1 in a' file1 file2
- gawk -F, '
- FNR==NR {a[NR]=$1; next};
- {b[$1]=$0}
- END{for (i in a) if (a[i] in b) print b[a[i]]}
- ' file1 file2
- awk -F, 'FNR==NR {a[$1]=$0; next}; $1 in a {print a[$1]}' file2 file1
- join -t, -1 2 -2 1 <(nl -s, -ba -nrz file1 | sort -t, -k2)
- <(sort -t, -k1 file2) | sort -t, -k2 | cut -d, -f1,3-
- air,000001,4,21,01,13,3,2
- cat,000006,1,5,6,3,1
- dude,000004,1,31,42,1
- hand,000003,1,4,2,1,6
- road,000005,1,4,2,1,4
- smell,000002,21,4,2,5,6
- air,4,21,01,13,3,2
- smell,21,4,2,5,6
- hand,1,4,2,1,6
- dude,1,31,42,1
- road,1,4,2,1,4
- cat,1,5,6,3,1
- grep -f file1 file2
Add Comment
Please, Sign In to add comment