0

I have two files. I want to copy source file to destionation file. If they are different, then I just want to copy different line not all file. In the below case, two line are same, but destination has extra line. How can I just delete last line of destination file?

For example:

Source File:

test1  
test2

Destionation File:

test1
test2  
test3
4
  • 1
    On which operating system? Commented Oct 19, 2015 at 18:03
  • linux operating system Commented Oct 19, 2015 at 18:05
  • Do you need to program it in C, or is the end result all you need? If you don't care about the logic, then piping the files to the linux command uniq may be a good choice. Commented Oct 19, 2015 at 18:08
  • What about rewriting the file while excluding the missing section? Commented Oct 19, 2015 at 20:54

1 Answer 1

4

On POSIX systems, if you want to delete some ending bytes in a file, you could use ftruncate(2)

There is no portable way to remove bytes in the middle of a file.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.