-4

I am using cp command in my program to make a copy of a text file. But when I use -p -i with cp I don't understand the difference between the both.

What's the difference between using simple cp and using options -p -i with it? Here is my line code:

execl("/bin/cp","cp","-p","-i",argv[1],argv[2],NULL);
Sathyajith Bhat
  • 21,321
  • 22
  • 95
  • 134

1 Answers1

0

The -i stands for interactive mode, this will require input from the stdin before it will overwrite a file. The -p (no capital p) will preserve mode ownership and timestamp. The latter one seems the more interesting one, this will actually cause a difference in your mss. When you're copying a file there is an owner of the file and there are different file permissions and a timestamp attached to it, if you want to keep these then use the -p parameter.

Steven Stip
  • 387
  • 3
  • 11