Course: Linux Administration Bootcamp

Comparing and Searching Files Using Pipes in Linux

This guide will demonstrate the procedure of comparing files in Linux distribution and searching files using pipes. The pipe is a type of redirection which is used to transfer the output to another destination.

The “$ diff” command is used to show the difference between two files with line numbers in Linux distribution. Different options are available that are used to compare and get information about differences that are executed with the “diff” utility. Some of them are provided in below table:

Command Description
$ diff Use to show the difference between two files with line number
$ diff -y -w 60 Use to display line-by-line comparison
$ diff -q Use to display only files that have a difference or not

To search files in Linux using pipes, below stated commands are utilized:

Command Description
$ ls | grep Used to search and display the particular file
$ find -name ‘<particular-extension>’ | xargs cat Use to search files with specified extension and display their content

As you can see, we have provided multiple commands to compare and find files using pipes. For more detail, move toward the below-attached video.

About the author

Talha Saif Malik

Talha is a contributor at Linux Hint with a vision to bring value and do useful things for the world. He loves to read, write and speak about Linux, Data, Computers and Technology.