![]() |
| | #1 |
| Registered User Join Date: Aug 2002
Posts: 351
| OT:force overwrite with cp The following do not work: -f --force --remove-destination Any ideas? rotis23 |
| rotis23 is offline | |
| | #2 |
| C++ Developer Join Date: Jun 2002 Location: UWaterloo
Posts: 2,718
| According to the man page, -f should work. What's the entire command you're using?
__________________ Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie |
| XSquared is offline | |
| | #3 |
| Registered User Join Date: Aug 2002
Posts: 351
| Try this to recreate: Code: touch /tmp/file touch file cp -f file /tmp |
| rotis23 is offline | |
| | #4 |
| C++ Developer Join Date: Jun 2002 Location: UWaterloo
Posts: 2,718
| Try doing this: Code: touch /tmp/file touche file cp -f file /tmp/
__________________ Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie |
| XSquared is offline | |
| | #5 |
| Registered User Join Date: Aug 2002
Posts: 351
| No difference with trailing slashes. It's a permissions thing. If I create the file as a user in /tmp I can cp without a confirmation (even without a -f). But if you su to root, confirmation is required. I still confused. |
| rotis23 is offline | |
| | #6 |
| Registered User Join Date: Aug 2002
Posts: 351
| example: Code: [rotis23@cabbage rotis23]$ touch /tmp/file [rotis23@cabbage rotis23]$ cp file /tmp [rotis23@cabbage rotis23]$ su Password: [root@cabbage rotis23]# cp file /tmp cp: overwrite `/tmp/file'? y [root@cabbage rotis23]# exit exit [rotis23@cabbage rotis23]$ cp file /tmp [rotis23@cabbage rotis23]$ |
| rotis23 is offline | |
| | #7 |
| C++ Developer Join Date: Jun 2002 Location: UWaterloo
Posts: 2,718
| Code: mlawrence@xanthus mlawrence $ touch /tmp/file mlawrence@xanthus mlawrence $ touch file mlawrence@xanthus mlawrence $ cp file /tmp mlawrence@xanthus mlawrence $ su - Password: xanthus root # touch file xanthus root # cp file /tmp xanthus root # exit logout mlawrence@xanthus mlawrence $ cp file /tmp mlawrence@xanthus mlawrence $
__________________ Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie |
| XSquared is offline | |
| | #8 |
| Registered User Join Date: Aug 2002
Posts: 351
| Weird - I tried 'su -' but still no difference. I've tested using redhat 8 and 9. What unix are you using XSquared. BTW vegetables are the new mythological creatures! |
| rotis23 is offline | |
| | #9 |
| End Of Line Join Date: Apr 2002
Posts: 6,240
| Show us an "ls -al" for that file before and after. Check your umask settings for each user. These will affects the default file permissions for new files. >>cp -f source target should do you. Can you show the output for it failing?
__________________ When all else fails, read the instructions. If you're posting code, use code tags: [code] /* insert code here */ [/code] |
| Hammer is offline | |
| | #10 |
| C++ Developer Join Date: Jun 2002 Location: UWaterloo
Posts: 2,718
| I'm runnin' Gentoo with a 2.6.5 kernel. Just for reference, I've included the ls -al before and after. Code: Before: -rw-r--r-- 1 mlawrence users 0 Jul 5 20:42 /tmp/file After: -rw-r--r-- 1 mlawrence users 0 Jul 5 20:42 /tmp/file
__________________ Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie |
| XSquared is offline | |
| | #11 |
| Registered User Join Date: Aug 2002
Posts: 351
| Found the problem - alias!! cp is aliased to 'cp -i'!! Code: [root@cabbage cmasters]# alias alias cp='cp -i' |
| rotis23 is offline | |
| | #12 | |
| Registered User Join Date: Mar 2003 Location: Louisiana
Posts: 926
| Quote:
| |
| linuxdude is offline | |
| | #13 |
| . Join Date: Nov 2003
Posts: 293
| Several Linux distros do that to prevent overwriting files in places like '/' with commands like 'cp * /' issued by newbies. |
| jim mcnamara is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| using the cp command in a program in os x | peateargriffin | C Programming | 22 | 04-08-2006 11:52 PM |
| how to overwrite the text in *.txt | SuperNewbie | C# Programming | 4 | 11-10-2003 09:01 AM |
| Add not overwrite to a file | Bones | C++ Programming | 7 | 10-03-2003 09:56 AM |
| Overwrite data in a file | SMurf | Windows Programming | 5 | 12-16-2002 01:40 PM |
| File opens, but won't overwrite | Brown Drake | C++ Programming | 0 | 11-23-2001 08:31 AM |