bash - Taking a Column of Output from comm Without Losing Blank Lines -
i'm trying assemble list of software installations per user. have complete list of users in file1.txt, , list of users software installed in file2.txt. want end lines in file1.txt or in both file1.txt , file2.txt, including blank lines. so:
file1.txt
bhope bsmith fjones jdoe zdirks file2.txt
bhope jdoe zdirks i can partway there comm -2 file1.txt file2.txt, gives me:
<tab>bhope bsmith fjones <tab>jdoe <tab>zdirks i want output be:
bhope <blank line> <blank line> jdoe zdirks with bonus points replacing actual output lines "y"'s:
y <blank line> <blank line> y y but can't find way preserve blank lines cut or awk.
assuming have fixed sorted problem:
comm -2 file1.txt file2.txt | awk -f'\t' '{print (nf==2?"y":"")}' y y y
Comments
Post a Comment