Skip to Content
Linux Shell Scripting Cookbook - Third Edition
book

Linux Shell Scripting Cookbook - Third Edition

by Clif Flynt, Sarath Lakshman, Shantanu Tushar
May 2017
Beginner
552 pages
28h 47m
English
Packt Publishing
Content preview from Linux Shell Scripting Cookbook - Third Edition

How to do it...

The diff utility reports the differences between two files.

  1. To demonstrate diff behavior, create the following files:

File 1: version1.txt

         this is the original text 
         line2 
         line3 
         line4 
         happy hacking ! 

File 2: version2.txt

       this is the original text  
       line2 
       line4 
       happy hacking !  
       GNU is not UNIX 
  1. Nonunified diff output (without the -u flag) is:
        $ diff version1.txt version2.txt 
        3d2
        <line3
        6c5
        > GNU is not UNIX
  1. The unified diff output is:
        $ diff -u version1.txt version2.txt
        --- version1.txt  2010-06-27 10:26:54.384884455 +0530 
        +++ version2.txt  2010-06-27 10:27:28.782140889 +0530 
        @@ -1,5 +1,5 @@ 
        this is the original text 
        line2
        -line3
        line4    
        happy hacking ! 
        -
        +GNU is not UNIX

 The -u option produces a ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Linux Shell Scripting - Second Edition

Mastering Linux Shell Scripting - Second Edition

Mokhtar Ebrahim, Andrew Mallett

Publisher Resources

ISBN: 9781785881985