Describe working of diff and cmp file handling commands with example.

1 Answer

Answer :

Diff command: diff stands for difference. This command is used to display the differences in the files by comparing the files line by line. it tells us which lines in one file have is to be changed to make the two files identical.

$ cat file1

shukla p.k.

chanchal singh

s.n.dasgupta

chakroborthy

$_

$ cat file2

barun sengupta

shukla p.k.

anil agrawal

chowdhary

s.n.dasgupta

$_

$ diff file1 file2

oal

> barun sengupta

2c3, 4

-------

> anil agarwal

> chakroborthy

$_


the instruction oa1 indicates that a single line has to appended after line number 0 of the first file and the resultant line will have line number 1 and 2 nd file.

Cmp Command: cmp command in Linux/UNIX is used to compare the two files byte by byte and helps you to find out whether the two files are identical or not.

Example:
$ cmp chap1 chap2
chap1 chap2       differ : char 9, line1
$_

The two files are compared byte by byte and the location of the first mismatch is echoed to the screen. If the two files are identical then cmp displays no message, but simply returns the $ prompt.

The –l (list) option gives detailed list of the byte number and the differing bytes in octal for each character that differs in both the files. 
$ cat file1
abcd
xyz
$ cat file2
Abed
wxy
$_
image
 

Related questions

Description : Describe cat and rm file handling commands with example.

Last Answer : cat Command: Cat(concatenate) command is very frequently used in Linux. It reads data from the file and gives their content as output. It helps us to create, view, concatenate files. cat is ... and will delete all the files and sub-directories recursively of the parent directory. $ rm -r 

Description : Describe use of following commands with example: i) route ii) net stat

Last Answer : Route: Packets are transmitted from one computer to another. The route determines where the process starts and what computer system needs to send the packet for it to reach its destination. In ... or softwaredefined network interface) and network protocol statistics. Options of Netstat:

Description : Which file in MS-DOS contains internal commands that are loaded during Booting process? 1) IO.SYS 2) MSDOS.SYS 3) COMMAND.COM 4) CONFIG.SYS

Last Answer : 4) CONFIG.SYS

Description : Which file in MS-DOS contains internal commands that are loaded during Booting process? 1 IO.SYS 2 MSDOS.SYS 3 COMMAND.COM 4 CONFIG.SYS

Last Answer : 4 CONFIG.SYS

Description : With suitable example, explain CpiO and tar commands. 

Last Answer : cpio: The cpio command is one of standard Unix backup utilities. It stands for "copy in/out." It is much less well known and more rarely used Unix utility in comparison with tar. ... command creates the file archive test.tar from the two uncompressed files test1 and test2. 

Description : Write the general formats for file opening and file closing commands?

Last Answer : Ans: For Opening:- fp=fopen(“filename” , “mode”); where ‘fp’ refers to the file pointer. ‘filename’ refers to the name of the file to be opened. ‘mode’ refers to the mode of accessing data. For Closing:- fclose(fp); where fp denotes the file pointer.

Description : Which of the following commands is used to update access and modification times of a file? A. grep B. wc C. touch D. cat E. None of the above

Last Answer : C. touch

Description : GO BOTTOM and SKIP-3 commands are given one after another in a database file of 30 records. It shifts the control to (A) 28th record (B) 27th record (C) 3rd record (D) 4th record

Last Answer : (B) 27th record

Description : What is the full form of CMP ?

Last Answer : CMP full form Chittagong Metropolitan Police.

Description : Tetrahydrofolate is required as a coenzyme for the synthesis of (A) UMP (B) CMP (C) TMP (D) All of these

Last Answer : Answer : C

Description : Amethopterin and aminopterin decrease the synthesis of (A) TMP (B) UMP (C) CMP (D) All of these

Last Answer : Answer : A

Description : The first pyrimidine nucleotide to be formed in de novo synthesis pathway is (A) UMP (B) CMP (C) CTP (D) TMP

Last Answer : Answer : A

Description : Xanthosine monophosphate is an intermediate during de novo synthesis of (A) TMP (B) CMP (C) AMP (D) GMP

Last Answer : Answer : D

Description : Inosine monophophate is an intermediate during the de novo synthesis of (A) AMP and GMP (B) CMP and UMP (C) CMP and TMP (D) All of these

Last Answer : Answer : A

Description : PRPP glutamyl amidotransferase, the first enzyme uniquely committed to purine synthesis is feed back inhibited by (A) AMP (B) IMP (C) XMP (D) CMP

Last Answer : Answer : A

Description : The pyrimidine nucleotide acting as the high energy intermediate is (A) ATP (B) UTP (C) UDPG (D) CMP

Last Answer : Answer : C

Description : A pyrimidine nucleotide is (A) GMP (B) AMP (C) CMP (D) IMP

Last Answer : Answer : C

Description : A purine nucleotide is (A) AMP (B) UMP (C) CMP (D) TMP

Last Answer : Answer : A

Description : In an 8085 microprocessor, the instruction CMP B has been executed while the contentsof accumulator is less than that of register B. As a result carry flag and zero flag will berespectively (A) set, reset (B) reset, set (C) reset, reset (D) set, set

Last Answer : (A) set, reset

Description : What is the full form of CMP ?

Last Answer : Common Minimum Programme

Description : What is the result of cmp(3, 1)? a) 1 b) 0 c) True d) False

Last Answer : Answer: a Explanation: cmp(x, y) returns 1 if x > y, 0 if x == y and -1 if x < y

Description : Cheapest option for moving my car to a diff. State...

Last Answer : You could drive it.

Description : Anyone here had C Diff?

Last Answer : C diff? That is quite a reach. If anyone here had it would make no difference for you. You need a diagnosis, not a comparison of symptoms. Antibiotics often make changes temporarily in the digestive system. ... is C diff, you don't want to sit around chatting about it, you want to get treated.

Description : What's the diff. between "I feel sick" and "I feel sickly"?

Last Answer : i think sickly implies a constant sort of icky, sick fatigue. sick is a physiological thing.

Description : Does anyone still care about the diff. between it's & its?

Last Answer : answer:Ha! Yes, people still care, and by people, I mean English teachers and proofreaders. The distinction between the two is observed in every print (and web) publication, and I think messing up ... actually useful!) but I like to think that it still makes you look dumb to confuse the two.

Description : Do you still have to remember usernames with "SuperGenPass"? what about password lenght requirements that are diff on diff sites, also: any alternatives you guys use that's 100% hacker safe?

Last Answer : answer:i just use the same…i don’t care that people see me on empornium etc. but ofcourse, everything will never be fully hackproof…

Description : Column 1,2 and 3 contain starting materials, reaction conditions, and type of reactions, respectively The only CORRECT combination that gives two diff

Last Answer : Column 1,2 and 3 contain starting materials, reaction conditions, and type of reactions, respectively The only CORRECT ... )(i)(S) D. (III)(iii)(P)

Description : how can i the diff between a female geese or male gander ?

Last Answer : There is no way to visually tell the difference between male and female Goose. This species is 76-110 cm (30-43 in) long with a 127-180 cm (50-71 in) wing span.[3] Males usually ... or a drawn out whinny - "wheee-oow". Anyone who has raised domestic geese will immediately recognize these calls.

Description : As shown in the illustrations, fine adjustments such as 'weather' and 'turning rate' have no effect on steering stand operation when the 'operation control switch' is in ____________. EL-0097 A. GYRO B. HAND C. NFU D. DIFF

Last Answer : Answer: C

Description : What is the main diff. bet. Reports 2.0 & Reports 2.5?

Last Answer : Report 2.5 is object oriented.

Description : Diff. between VAT and Property Class? imp

Last Answer : Named visual attributes define only font, color, and pattern attributes; property classes can contain these and any other properties. You can change the appearance of objects at runtime by ... visual attribute settings take precedence, and any visual attribute properties in the class are ignored.

Description : What are OPEN_FORM,CALL_FORM,NEW_FORM? diff?

Last Answer : CALL_FORM : It calls the other form. but parent remains active, when called form completes the operation , it releases lock and control goes back to the calling form. When you call a form, Oracle Forms ... was a called form, Oracle Forms runs the new form with the same options as the parent form.

Description : What is the diff. bet. setting up of parameters in reports 2.0 reports2.5?

Last Answer : LOVs can be attached to parameters in the reports 2.5 parameter form.

Description : What is the diff. when confine mode is on and when it is off?

Last Answer : When confine mode is on, an object cannot be moved outside its parent in the layout.

Description : What is the diff. when Flex mode is mode on and when it is off?

Last Answer : When flex mode is on, reports automatically resizes the parent when the child is resized.

Description : If a parameter is used in a query without being previously defined, what diff. exist betw. report 2.0 and 2.5 when the query is applied?

Last Answer : While both reports 2.0 and 2.5 create the parameter, report 2.5 gives a message that a bind parameter has been created.

Description : What is the diff. between electronic regulator and ordinary rheostat regulator for fans?

Last Answer : The difference between the electronic and ordinary regulator is that in electronic reg. power losses are less because as we decrease the speed the electronic reg. give the power needed for ... speed is controlled but in rheostatic control resistance is decreased by steps to achieve speed control.

Description : What is the diff. btwn. Electronic regulator and ordinary rheostat regulator for fans?

Last Answer : A: The difference between the electronic and ordinary regulator is the fact that in electronic reg. power losses tend to be less because as we minimize the speed the electronic reg. give ... speed is controlled but in rheostatic control resistance is decreased by steps to achieve speed control.

Description : I put myself as a OP on a server for minecraft and none of the commands are working what do I do?

Last Answer : answer:Make sure you’re putting the / before your server commands, of course. Otherwise, try and restart the server. Some changes like enabling monsters take time and a few restarts occasionally.

Description : In gw basic what are the two types of file handling?

Last Answer : Sequential and random access.

Description : Why we use File Handling?

Last Answer : Ans: The input and output operation that we have performed so far were done through screen and keyboard only.After the termination of program all the entered data is lost because primary memory is volatile ... 2. Low level (system oriented files)- low level files handling is managed by system call.

Description : The ALU of a computer responds to the commands coming from A) Primary memory B) Control section C) External memory D) Cache memory

Last Answer : Answer : B

Description : Which is an escape code language used to send commands to the printer for printing documents? A. Postscript B. PCL C. Both (A) and (B) D. None of the Above

Last Answer : B. PCL

Description : _________ is a group of commands for a CPU in machine language. A. Information Set B. Instruction Set C. Buffer D. None of the Above

Last Answer : B. Instruction Set

Description : The toolbar which contains short cuts to some of the most frequently used commands found under the FORMAT menu item is: a) Standard Toolbar b) Status Bar c) Formatting Toolbar d) None of These

Last Answer : c) Formatting Toolbar

Description : ________toolbar contains short cuts to some of the most frequently used commands from the menu bar: a) Formatting Toolbar b) Standard Toolbar c) Both of Above d) None of These

Last Answer : b) Standard Toolbar

Description : ______bar displays the heading for each drop down menu. Commands are grouped under each of these menu headings according to function: a) Title Bar b) Formatting Toolbar c) Menu bar d) None of These

Last Answer : c) Menu bar

Description : Which among the following is correct about WRAM: a) Makes it easier to allow blocks of memory to be addressed with just a few commands b) Makes it easier to allow windows of memory to be addressed with just a few commands. c) Both of Above d) None of These

Last Answer : c) Both of Above

Description : _______is the process of carrying commands: a) Storing b) Executing c) Fetching d) None of These

Last Answer : b) Executing

Description : ______toolbar contains short cuts to some of the most frequently used commands from the menu bar: a) Standard b) Title c) Status Bar d) None of These

Last Answer : a) Standard