Find the answer to your Linux question:
Results 1 to 7 of 7
pretty new to linux, just wondering if there's a command to overwrite a directory....
  1. #1
    Just Joined!
    Join Date
    Jan 2010
    Posts
    3

    can i overwrite a directory

    pretty new to linux, just wondering if there's a command to overwrite a directory.

  2. #2
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,316
    Hi and Welcome !

    I am not getting it. What do you want to do exactly? Do want to change directory name, location or files in it?
    I would suggest you check linuxcommand.org for basic commands.
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  3. #3
    Just Joined!
    Join Date
    Jan 2010
    Posts
    3
    im trying to copy an updated directory over and have it replace the current one...

    and thanks for the link, im sure this site is going to come in handy!

  4. #4
    Linux Enthusiast meton_magis's Avatar
    Join Date
    Oct 2006
    Location
    arizona
    Posts
    665
    There are some switches to `cp` that would be useful.

    you can see all of the switches with
    `man cp`

    but there is a switch to recursively copy files in a directory
    `cp -r from_directory to_location`

    and to copy only files that have been updated.
    `cp -ru from_directory to_location`

    again, see the man page for a better look
    New to the internet, technical forums, or the hacker / open source community??
    Read this to learn good posting habits http://www.catb.org/~esr/faqs/smart-questions.html

    RHCE for RHEL version 5
    RHCT for RHEL version 4

  5. #5
    Just Joined!
    Join Date
    Jan 2010
    Posts
    3
    im not sure why, but the cp command isnt working. i get no error, but it just doesn't overwrite the old directory.


    little background...

    im in Android, if that matters, and have busybox on here as well.

    im attempting to copy a new, updated app folder onto the device. all i did was optipng the files from my app folder and im trying to replace the old ones with the updated optipng'd ones

  6. #6
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    So we have a directory and want to replace it with a new one?

    I don't necessarily know of a single command to do this (particularly if cp -u isn't working), but it's fairly simple in two commands:
    Code:
    rm -R olddir/
    cp -R newdir/ olddir/
    The first command deletes a directory, and the second one copies the new directory to the old one.
    DISTRO=Arch
    Registered Linux User #388732

  7. #7
    Trusted Penguin elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    2,298
    I would replace the first command with an mv - just in case
    If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)


    My new blog. It's probably not as good as I think it is.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...