![gedit command in linux with examples gedit command in linux with examples](https://phoenixnap.com/kb/wp-content/uploads/2021/04/lime-text-editor.png)
Oh yeah, I also need to buy grated cheese. Let’s look at another example, two text files should be like this. The options of the result should be like this –įrom the output, 2,4c2,4 means “Lines 2 through 4 in the first file needs to be changed in order to match lines 2 through 4 in the second file” The above command should give the result as shown below – diff /home/linux/Desktop/file.txt /home/linux/Desktop/file1.txt Use the diff command to compare both the files as shown below – diff /home/linux/Desktop/file.txt /home/linux/Desktop/file1.txt
![gedit command in linux with examples gedit command in linux with examples](https://miro.medium.com/max/799/1*KE6pExp3fCvUAX43vIce1w.png)
The data has been inserted into file.txt as shown below – I need to buy apples.įile1.txt contains the data as shown below I need to buy apples.
GEDIT COMMAND IN LINUX WITH EXAMPLES PATCH
![gedit command in linux with examples gedit command in linux with examples](https://2.bp.blogspot.com/-W1JHXkrsGso/TbBS7FxPQNI/AAAAAAAAAho/VFXRGjdUNMc/s1600/unix-command-example-chmod.png)
So, if you want the diff command to report explicitly that the files are same then use -s command line option. Though this default behavior is fine but it could still confuse many, especially the newbies. Towards the end of the example 1, we saw that diff doesn't report anything if files are same. 2) Report That The Files Are Same Using -s Option So you can see that no output was produced, which is the default behaviour when both the files are same. Here is an example : $ diff -i file1 file2 To get away with this default behaviour, use -i option. So you can see that the diff command reported the case difference in the output. If two files contain same text but in different cases, the diff command still reports it as a difference by default. Here are some of the commonly used command line options : 1) Use -i to ignore case differences So you can see that when diff command is executed to compare these two directories, it easily displays the missing files in the directories. Now, here is the output when diff command was executed : $ diff new_dir/ orig_dir/ Here are the contents of a directory named 'new_dir' : $ ls new_dir/įile file2 frnd frnd1.cpp log1.txt log3.txt log5.txtįile1 file name with spaces frnd1 frnd.cpp log2.txt log4.txtĪnd here are the contents of a directory named 'old_dir' : $ ls orig_dir/įile1 file name with spaces frnd1 frnd.cpp log2.txt log4.txt testįile2 frnd frnd1.cpp log1.txt log3.txt log5.txt In addition to files, the diff command can also be used to compare two directories. The lines to be added and deleted are marked with > and represents the line to be added. Here, the line 4,5c4 means that the line numbers ranging from 4 to 5 in the old file are now changed and should be replaced with the 4th line of the new file. The line to be added is displayed in the next line of the output with > mark. Here, the line 2a2 means that the second line from the new file should be added after second line of old file.