Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please I need this answers ASAP for Linux Class. Lab Writeup Explain what the fo

ID: 3590040 • Letter: P

Question

Please I need this answers ASAP for Linux Class.

Lab Writeup

Explain what the following diff outputs and patch commands would do.

Chunk 1:

1c1
< // this is the original file
---
> // this is the new file

Chunk 2:

2a3
> // Additional comments added to the new file

Chunk 3:

7a9,11
> class Time; // forward reference
> istream &operator >> (istream &, Time &);
>

Chunk 4:

8a13
> friend ostream &operator<<(ostream &, const Time &);

Chunk 5:

13a19
> Time &setTime( const Time & ); // set Time object

Chunk 6:

25d30
< void printMilitary() const; // print military time

7. Assume you had the following output in a file called diff_file:

--- hw4_2.cpp 2009-11-18 14:54:47.000000000 -0800
+++ hw4_2b.cpp 2009-11-18 14:56:04.000000000 -0800
@@ -14,18 +14,14 @@
int size; // Current number of elements in nums
double avg, stdev;

- cout << "How many integers do you wish to enter? ";
- cin >> size;
-
// Validate that size is between 2 and MAX_SIZE. We use 2 as the lower bound
// since you cannot compute standard deviation with only 1 value. Validation
// loops always use the inverse of the desired values as the while statement
- while(size < 2 || size > MAX_SIZE)
+ do
{
- cout << "Invalid size. Valid sizes are 2 to " << MAX_SIZE;
- cout << ". How many integers? ";
+ cout << "How many integers do you wish to enter (2 to " << MAX_SIZE << ")? ";
cin >> size;
- }
+ } while(size < 2 || size > MAX_SIZE);

// Now we can prompt the user for each integer
for(int i = 0; i < size; i++)

What would the command patch -p0 <diff_file do?

Explanation / Answer

diff is used to get the differences between two files
usage diff new-file updated-file


chunk1: 1c1 ==> c indicates that replace the file content of lines at line number 1
chunk2: 2a3 ==> a meand append, so append original 2nd line to updated 3rd line
chunk3: 7a9,11 ==> a indicates append, so append 7th line to both 9, 11 lines
chunk 4: 8a13 --> a includes append , so append 8th line to 13th line
chunk 5: 13a19 --> a includes append , so append 13th line to 19th line
chunk 6: 25d30 --> d includes delete, so changes in old file line number 25th are deleted in new file 30th line.

7)
compared two files...
--- hw4_2.cpp 2009-11-18 14:54:47.000000000 -0800

+++ hw4_2b.cpp 2009-11-18 14:56:04.000000000 -0800

and @@ -14,18 +14,14 @@
includes from first line 14 changes deleted and 18 chages added
From second file 14 new changes added and 14 changes updated.

8) -p n ===> will delete n components from the start of all path_names in the given patch file
So -p0 means deleting 0 components from patch file