![]() ![]() Use ‘-c’ option in diff command to produce the diff command output in context format. Output of diff command “ 7d6” indicates that we need to delete 7th line in the first file to sync with the second file at line number 6. Let’s remove “Arch Linux” and “Fedora” from sydney.txt and then try to compare these files, ![]() Output of diff command “ 7a8” indicates that after the 7th line in the first file, we need to add another line to match 8th line of the second file. Let’s roll-back the above change and add a new line “ Arch Linux” in sydeny.txt at end of file and run the diff command again, In the output, 1c1 indicates that 1st line of the first file needs to be changed to make both the files identical. Now re-run the diff command, ~]# diff aachen.txt sydney.txt Let’s make some changes in aachen.txt, re-write open source as “ open-source”. Let’s compare the content of these files using diff command, ~]# diff aachen.txt sydney.txtĪbove output confirms that both the files are identical. Linux Rocks in the open source world, followings are the linux distributions: Let’s assume we have two files aachen.txt and sydney.txt and following is the content of these files, ~]# cat aachen.txt In this post, we will discuss diff command with practical examples. d -> it indicates some text has been deletedīy default, diff command displays the output in normal format, it means when contents of two files are identical then it will not produce any output but we will get the prompt.c -> it indicates that some text has been changed.a -> it indicates that something has been added. ![]() Output of diff command can be in following format:ĭifferent symbols of diff command output: Diff command plays an important in shell script where we want to run command based on the comparison of two files. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |