comand cp and mv
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix administration > comand cp and mv




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    comand cp and mv  
blackdog


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-08-05 01:48 AM

I have an application which is written in C. The application contains
command cp to copy a file to another file name, then use
command rm to delete the original file. Some people think that is
better then using command mv in a C program to rename a file because
the mv command dose not always work in a C program, it get hung
sometime.
Would anyone please explain why and why not?

Thanks.






[ Post a follow-up to this message ]



    Re: comand cp and mv  
Barry Margolin


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-08-05 01:48 AM

In article <1112919832.716926.163690@o13g2000cwo.googlegroups.com>,
"blackdog" <cljlk@hotmail.com> wrote:

> I have an application which is written in C. The application contains
> command cp to copy a file to another file name, then use
> command rm to delete the original file. Some people think that is
> better then using command mv in a C program to rename a file because
> the mv command dose not always work in a C program, it get hung
> sometime.
> Would anyone please explain why and why not?

The mv command will use rename() if the source and destination are on
the same filesystem, which is *much* better.

If they're on different filesystems, mv works like cp followed by rm.
If cp succeeds, so should mv.  You should probably use the -f option to
prevent mv from asking questions.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 02:00 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register