basic shell programming

awk, bash, shell

Solution

Use `sort` and `uniq`

sort a b | uniq -u

If you want the lines that are the same between A and B, you can use `uniq -d`

sort a b | uniq -d

This assumes of course that the data in A and B are exactly the same. There cannot be any lose spaces or tabs in the datasets. If there are, you'll have to clean up the data with `sed`, `tr`, or `awk` first.

Edit

As Peter. O pointed out, this will fail if there happen to be exact duplicates in file `a`. If that's an issue, you can fix it by doing this:

sort <(sort -u a) b | uniq -u

Problem

Probably this is a very basic question for shell programmers. But suppose I have a text file A and B and B is a subset of A. I want to create a text file C which contains (A-B) data. So omit all the common lines . The line in files are numeric data: like ``` id , some aspect, other aspec. ``` Thanks.

Original source