1
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 5 years have passed since last update.

コマンドプロンプトのfcコマンド

Posted at

windowsのコマンドプロンプトでファイル比較を行う場合、fcコマンドを使用すると思いますが、
よくわからない挙動をしました。

~手順~

①比較するファイルを2つ用意する。
 改行とか文字コードとか細かい部分の差異がでるといけないのでtest.txtを作成したあとに
 文字列をコピーするのではなくファイルをコピーしてファイル名をリネームする

D:\>
D:\>type test.txt
aaa
bbb
ccc

D:\>type test2.txt
aaa
bbb
ccc

D:\>

②この時点で差異がないことを確認する

D:\>
D:\>fc /n test.txt test2.txt
ファイル test.txt と TEST2.TXT を比較しています
FC: 相違点は検出されませんでした


D:\>

③test2.txtを編集する。
 これも改行コードとか他のものが変わらないように真ん中の文字を変更(ccc ⇒ cdc)

D:\>
D:\>type test2.txt
aaa
bbb
cdc

D:\>

④ファイルを再度比較する。

D:\>
D:\>fc /n test.txt test2.txt
ファイル test.txt と TEST2.TXT を比較しています
***** test.txt
    2:  bbb
    3:  ccc
***** TEST2.TXT
    2:  bbb
    3:  cdc
*****


D:\>

となります。
予想では3行目だけ差異が検出されると思ってますが、
実際には2行目も差異が検出されているようです。

これってなんででしょう。

単純に差異が出たところの上下の行も表示する仕様?

1
1
4

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