0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Linuxコマンド】ファイル間の差分(diff)を取る方法

Last updated at Posted at 2025-02-21

ローカル環境下でファイル同士に差が生まれていないか、確認したい時があると思います。
そのような場合は下記コマンドで確認ができます。

diff [ファイル1] [ファイル2]

【first_test.txt と second_test.txt のファイルに差がない場合】

% diff first_test.txt second_test.txt
%

【first_test.txt と second_test.txt のファイルに差がある場合】

% diff first_test.txt second_test.txt
1c1
< テスト
\ No newline at end of file
---
> テストです
\ No newline at end of file
%

first_test.txt の1行目は「テスト」と書かれていることに対し、
second_test.txt の1行目は「テストです」と書かれていますよーって感じで差分が出てることが結果からわかりますね。

このような感じでファイルの差分を確認することができました。

最後までご覧いただきありがとうございました。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?