SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Linux Command -> move and overwrite

    Hi,

    I have a server which i runs linux, and i have two folders: 'old' and 'new'.
    The 'new' folder does not contain all the files in 'old', of which i need, so i want to move 'new' into 'old' and overwrite any neccessary files.

    i.e
    new
    -- a.html
    --b.html


    old
    --a.html
    --b.html
    --c.html

    After the update, 'old' should contain:
    --a.html (the vesrion from 'new')
    --b.html (the vesrion from 'new')
    --c.html

    Anyone know what commands i'd use?

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Code:
    cd new
    mv -u *.html ../old/
    The -u flag means "update", or only overwrite the file if it's newer than the one in the directory you're moving the file to. If you want to force the overwrite no matter what, use the -f flag instead.

  3. #3
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks,

    That worked almost perfectly, just it doesn't do recursive directories and the help on mv didn't show a recursive option, so i did it manually.

    Thanks again,
    -Peter


Bookmarks

Posting Permissions

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