The Issue of the Day Before

用 shell script 進行集合計算

linux -
  • a-b sort a.file b.file b.file | uniq -u

  • ab sort a.file b.file | uniq

  • ab sort a.file b.file | uniq -d

How

a.fileb.file 兩個檔案,裡面各自含以不重複的行構成的資料。 可利用下列方法各自求出兩個檔案內容的交集,聯集與差集。

a-b

sort a.file b.file b.file | uniq -u

a b

ab

sort a.file b.file | uniq

a b

ab

sort a.file b.file | uniq -d

a b

閱讀在雲端