6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

diffコマンドで片方のファイルにしかないものを抽出

Posted at

はじめに

新旧の2つのファイルが、新しい方だけにあるものを抽出したいケースがあります。
(例えば、insertとupdateを別々に処理するなど)

diffコマンドで、差分の内容を制御するオプションがあるので、それを使ってやります。

使用例

$ cat old.txt
1
2
3
4
8
9
$ cat new.txt
1
2
3
4
5
6
7
8
9
$ diff --old-line-format='' --unchanged-line-format='' --new-line-format='%L' old.txt new.txt
5
6
7

参考リンク

6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?