3 ms·
Common lines between 2 files awk 'NR==FNR{a[$0]; next} $0 in a' colors_1.txt colors_2.txt http://archive.vn/mmd80 http://archive.vn/mmd80
by known 7y ago
Common lines between 2 files
awk 'NR==FNR{a[$0]; next} $0 in a' colors_1.txt colors_2.txt
http://archive.vn/mmd80 http://archive.vn/mmd80
- mkl 7y agoThe link doesn't load for me, but that seems pretty unreadable. I'd probably sort, merge, and print duplicates: sort -m <(sort -u file1) <(sort -u file2) | uniq -d
- asicsp 7y agoyou can use comm as well # common lines comm -12 <(sort file1) <(sort file2) # lines unique to first file comm -23 <(sort file1) <(sort file2) # lines unique to second file comm -13 <(sort file1) <(sort file2) regarding readability, it is the same with any new tool or programming language, you'd need to be familiar with its syntax and idioms, someone not familiar with command line and sort/uniq commands will find your solution as alien as well
- asicsp 7y agoI've recently modified and published that tutorial as an ebook [1], which can be read from the github repo or downloaded as PDF (currently free). I am also updating the book to include exercises, other minor improvements as well as epub version - expected release by next weekend. [1] https://github.com/learnbyexample/learn_gnuawk https://github.com/learnbyexample/learn_gnuawk