[LINUX] I want to display only different lines of a text file with diff

diff

diff data1.txt data2.txt

And when used normally

--- data1.txt
+++ data2.txt
@@ -1,4 +1,4 @@
 11111
-22222
+22225
 33333
-44444
+44445

Lines with the same content and lines with different contents are displayed as a mixture. I thought it was a little hard to see when there were many lines.

sed The beginning of the same line is blank, so filter (delete) with sed.

sed -e '/^ .\+/d'

"^" ". \ +" Starting with a space means to delete any character string with d.

Connect with diff with a pipe.

diff data1.txt data2.txt | sed -e '/^ .\+/d'

Then

--- data1.txt
+++ data2.txt
@@ -1,4 +1,4 @@
-22222
+22225
-44444
+44445

It was refreshing with only different lines.

Recently I've been studying shells using busybox on Windows, but it's deep.

Recommended Posts

I want to display only different lines of a text file with diff
I want to write to a file with Python
I want to do a full text search with elasticsearch + python
I want to display multiple images with matplotlib.
I want to make a game with Python
Find out how to divide a file with a certain number of lines evenly
I want to write an element to a file with numpy and check it.
I want to add silence to the beginning of a wav file for 1 second
I tried to create a table only with Django
I want to transition with a button in flask
I want to climb a mountain with reinforcement learning
Convert a text file with hexadecimal values to a binary file
I want to randomly sample a file in Python
I want to work with a robot in python.
I want to split a character string with hiragana
I want to install a package of Php Redis
I want to manually create a legend with matplotlib
I want to run a quantum computer with Python
I want to bind a local variable with lambda
[Python] I want to use only index when looping a list with a for statement
I want to save a file with "Do not compress images in file" set in OpenPyXL
I want to specify another version of Python with pyvenv
I want to make a blog editor with django admin
I want to start a jupyter environment with one command
I want to start a lot of processes from python
I want to make a click macro with pyautogui (desire)
I want to use only the normalization process of SudachiPy
NikuGan ~ I want to see a lot of delicious meat! !!
I want to color black-and-white photos of memories with GAN
I want to make a click macro with pyautogui (outlook)
How to display a list of installable versions with pyenv
I want to use a virtual environment with jupyter notebook!
I want to install a package from requirements.txt with poetry
[Visualization] I want to draw a beautiful graph with Plotly
[Python] I want to make a 3D scatter plot of the epicenter with Cartopy + Matplotlib!
I want to do ○○ with Pandas
I want to debug with Python
I want to use a wildcard that I want to shell with Python remove
I want to solve APG4b with Python (only 4.01 and 4.04 in Chapter 4)
[Introduction to StyleGAN] I played with "The Life of a Man" ♬
I want to output the beginning of the next month with Python
I tried to create a list of prime numbers with python
[Introduction] I want to make a Mastodon Bot with Python! 【Beginners】
I want to check the position of my face with OpenCV!
I tried to make a mechanism of exclusive control with Go
I want to create a graph with wavy lines omitted in the middle with matplotlib (I want to manipulate the impression)
I want to extract the tag information (title and artist) of a music file (flac, wav).
When generating a large number of graphs with matplotlib, I do not want to display the graph on the screen (jupyter environment)
I want to detect objects with OpenCV
I tried to implement a blockchain that actually works with about 170 lines
I want to print in a comprehension
I want to send a signal only from the sub thread to the main thread
(Matplotlib) I want to draw a graph with a size specified in pixels
I want to blog with Jupyter Notebook
Extract lines that match the conditions from a text file with python
I want to build a Python environment
I want to pip install with PythonAnywhere
Create a large text file with shellscript
I want to analyze logs with Python
I want to sort a list in the order of other lists
I want to play with aws with python