5
1

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 1 year has passed since last update.

Windowsでdiff, patchする

Last updated at Posted at 2022-12-06

Windowsでdiff, patchする手順です。Git Bashを使います。

例:a.txtb.txtの差分をa.txtに適用する

$ cat Desktop/a.txt
hoge hoge hoge
hoge hoge hoge
hoge hoge hoge

$ cat Desktop/b.txt
hoge hoge hoge
hoge fuga hoge
hoge hoge hoge
$ diff -u Desktop/a.txt Desktop/b.txt > Desktop/hoge2fuga.patch

$ dos2unix Desktop/hoge2fuga.patch
dos2unix: converting file Desktop/hoge2fuga.patch to Unix format...

$ patch -p0 < Desktop/hoge2fuga.patch
patching file Desktop/a.txt

$ unix2dos Desktop/a.txt
unix2dos: converting file Desktop/a.txt to DOS format...

$ cat Desktop/a.txt
hoge hoge hoge
hoge fuga hoge
hoge hoge hoge

Powershellコマンドでの組み上げに断念したのでご存知の方はコメントくださると幸いです。

5
1
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
5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?