+ Reply to Thread
Results 1 to 9 of 9

How to suppress cp "Do you want to overwrite" prompt?

  1. How to suppress cp "Do you want to overwrite" prompt?

    Hi,

    After consulting the man pages, I'm still clueless as to how to
    suppress the prompt

    [me@localhost portal]# cp -r remote/* ./
    cp: overwrite `./bugtracker/account_delete.php'? y

    In other words, I want to default to "y" as the answer to all
    questions. There are too many files for me to do this individually
    for each one.

    I'm using Fedora Core 5 Linux.

    Thanks, - Dave


  2. Re: How to suppress cp "Do you want to overwrite" prompt?

    laredotornado@zipmail.com wrote:
    > Hi,
    >
    > After consulting the man pages, I'm still clueless as to how to
    > suppress the prompt
    >
    > [me@localhost portal]# cp -r remote/* ./
    > cp: overwrite `./bugtracker/account_delete.php'? y
    >
    > In other words, I want to default to "y" as the answer to all
    > questions. There are too many files for me to do this individually
    > for each one.
    >


    try cp -fr

    just be really careful since cp takes the "f" seriously

    Stan
    --
    Stan Bischof ("stan" at the below domain)
    www.worldbadminton.com

  3. Re: How to suppress cp "Do you want to overwrite" prompt?

    stan@worldbadminton.com wrote:
    >> for each one.
    >>

    >
    > try cp -fr
    >
    > just be really careful since cp takes the "f" seriously
    >


    for a more general solution, see the "yes" command

    Stan
    --
    Stan Bischof ("stan" at the below domain)
    www.worldbadminton.com

  4. Re: How to suppress cp "Do you want to overwrite" prompt?

    On Thu, 14 Jun 2007 19:59:28 -0000, laredotornado@zipmail.com wrote:
    > Hi,
    >
    > After consulting the man pages, I'm still clueless as to how to
    > suppress the prompt
    >
    > cp: overwrite `./bugtracker/account_delete.php'? y


    Three options:
    o unalias the cp alias
    o /bin/cp -r remote/* ./
    o cp -fr remote/* ./

  5. Re: How to suppress cp "Do you want to overwrite" prompt?

    > [me@localhost portal]# cp -r remote/* ./ cp: overwrite
    > `./bugtracker/account_delete.php'? y


    You probably have an alias for cp that includes the verify prompt. Try
    prefixing it with \ to ignore the alias. The default behavior is to not
    prompt. But I could be wrong.

    $ \cp -r remote/* ./

    $ alias
    (to see what alias it might have, if any)

    $ unalias cp
    (to remove said alias)

    $ help alias
    (for info on how to use alias via bash)

    HTH

  6. Re: How to suppress cp "Do you want to overwrite" prompt?

    On Thu, 14 Jun 2007 20:17:18 +0000, Shadow_7 wrote:

    >> [me@localhost portal]# cp -r remote/* ./ cp: overwrite
    >> `./bugtracker/account_delete.php'? y

    >
    > You probably have an alias for cp that includes the verify prompt. Try
    > prefixing it with \ to ignore the alias. The default behavior is to not
    > prompt. But I could be wrong.


    Correct, both for the real default and the very common alias settings to
    put -i as an option for rm, cp and mv

    Note that all three obey the last -f or -i given, so if cp is aliased to
    cp -i, then cp -f will be evaluated as cp -i -f with the -f given force.

    --
    Phoenix

  7. Re: How to suppress cp "Do you want to overwrite" prompt?

    On 14 Jun, 21:17, Shadow_7 wrote:
    > > [me@localhost portal]# cp -r remote/* ./ cp: overwrite
    > > `./bugtracker/account_delete.php'? y

    >
    > You probably have an alias for cp that includes the verify prompt. Try
    > prefixing it with \ to ignore the alias. The default behavior is to not
    > prompt. But I could be wrong.
    >
    > $ \cp -r remote/* ./
    >
    > $ alias
    > (to see what alias it might have, if any)
    >
    > $ unalias cp
    > (to remove said alias)
    >
    > $ help alias
    > (for info on how to use alias via bash)
    >
    > HTH


    You are in luck - I had the same problem no more than an hour ago,

    It is Shadow_7 says : $ \cp -r remote/* ./

    I just found the solution in this redhat thread -
    http://www.redhat.com/magazine/019ma...s/tips_tricks/

    It looks like you didn't google well enough. :)


  8. Re: How to suppress cp "Do you want to overwrite" prompt?

    On 2007-06-14, laredotornado@zipmail.com wrote:
    > Hi,
    >
    > After consulting the man pages, I'm still clueless as to how to
    > suppress the prompt
    >
    > [me@localhost portal]# cp -r remote/* ./
    > cp: overwrite `./bugtracker/account_delete.php'? y
    >
    > In other words, I want to default to "y" as the answer to all
    > questions. There are too many files for me to do this individually
    > for each one.


    Get rid of the stupid and dangerous aliases. At the top of your
    .bashrc (and/or .bash_profile) put:

    unalias -a

    Execute that command at the prompt to clean up your current shell.

    --
    Chris F.A. Johnson, author |
    Shell Scripting Recipes: | My code in this post, if any,
    A Problem-Solution Approach | is released under the
    2005, Apress | GNU General Public Licence

  9. Re: How to suppress cp "Do you want to overwrite" prompt?

    To override cp's alias you can simply enclose it in quotes:
    Code:
    'cp' -rf ./source/* /destination/

+ Reply to Thread