Results 1 to 6 of 6

Thread: CP Suffix argument Help

  1. #1

    Angry CP Suffix argument Help

    Hey guys, I am hoping someone can help me use the suffix argument in cp. I have tried every variation google had to offer and still couldn't get it working. The background is that I want a folder copied to a slave hard drive each night, however if the same file exists I don't want it over written, but to have a number appended to it. I've gone through the man pages, but what I really want is an example of it's use and syntax. Thanks in advance.

  2. #2
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: CP Suffix argument Help

    AFAICT the --suffix option just overrides the default ~.

    What you want is actually the --backup=numbered option. See the man page. Here's an example:

    $ touch foo
    $ cp foo /tmp
    $ cp --backup=numbered foo /tmp
    $ ls /tmp/foo*
    /tmp/foo /tmp/foo.~1~

  3. #3
    Join Date
    Aug 2008
    Location
    Brazil
    Posts
    2,844

    Default Re: CP Suffix argument Help

    Thats WAAAAAY cool for a quick backup-now/check-later. Thanks!

    shell commands ARE fantastic! Now on to write a GUI

    But, can it do this only if files are different? (man page, I know

  4. #4
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    26,520
    Blog Entries
    15

    Default Re: CP Suffix argument Help

    Quote Originally Posted by brunomcl
    Thats WAAAAAY cool for a quick backup-now/check-later. Thanks!

    shell commands ARE fantastic! Now on to write a GUI

    But, can it do this only if files are different? (man page, I know
    Hi
    You may want to look at rsync then....

    --
    Cheers Malcolm (Linux Counter #276890)
    openSUSE 11.1 x86 Kernel 2.6.27.7-9-default
    up 10:28, 2 users, load average: 0.00, 0.00, 0.01
    GPU GeForce 6600 TE/6200 TE - Driver Version: 180.22


  5. #5

    Default Re: CP Suffix argument Help

    I've tried doing exactly what you have listed: cp -R --backup=numbered ./test1/ ./test2/ but nothing happens. It just copies the files from one directory to another over-writting the files already present.

  6. #6
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: CP Suffix argument Help

    $ cd /tmp
    $ mkdir test1 test2
    $ touch test1/foo test2/foo
    $ cp -R --backup=numbered test1/* test2/
    $ ls test2
    foo foo.~1~
    Looking at your command it looks like you would make a complete copy of test1 inside test2, maybe not what you had in mind. Try:

    Code:
    cp -R --backup=numbered test1/. test2/

Posting Permissions

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