How to use cp -u on a Solaris system which does not support the -u option?











up vote
3
down vote

favorite












I want to copy only when the SOURCE file is newer than the destination file or when the destination file is missing. As you know, this feature will work on Linux system on following command.



cp -u /source/*.txt /destination/  


but when i am using this command on solaris system 10. Below is my outut:



cp: illegal option -- u
Usage: cp [-f] [-i] [-p] [-@] f1 f2
cp [-f] [-i] [-p] [-@] f1 ... fn d1
cp -r|-R [-H|-L|-P] [-f] [-i] [-p] [-@] d1 ... dn-1 dn


Is there any solution?










share|improve this question
























  • Don't think you can.
    – 123
    Jan 27 '16 at 9:47










  • is there any way out?
    – Wasila
    Jan 27 '16 at 9:48










  • If your shell supports the if [ "$src" -nt "$dst ]; then … construct you can use that one (however, not it's not in POSIX). Do you have pax or rsync available? That might be the easiest solution.
    – Marco
    Jan 27 '16 at 9:55










  • I haven't tried pax yet. But I am unable to install rsync on my solaris system
    – Wasila
    Jan 27 '16 at 10:00










  • "cp" on Linux is usually from the GNU coreutils which are also available for Solaris - can you build & install software like that on your Solaris machine or are your privileges limited?
    – alanc
    Jan 27 '16 at 16:37















up vote
3
down vote

favorite












I want to copy only when the SOURCE file is newer than the destination file or when the destination file is missing. As you know, this feature will work on Linux system on following command.



cp -u /source/*.txt /destination/  


but when i am using this command on solaris system 10. Below is my outut:



cp: illegal option -- u
Usage: cp [-f] [-i] [-p] [-@] f1 f2
cp [-f] [-i] [-p] [-@] f1 ... fn d1
cp -r|-R [-H|-L|-P] [-f] [-i] [-p] [-@] d1 ... dn-1 dn


Is there any solution?










share|improve this question
























  • Don't think you can.
    – 123
    Jan 27 '16 at 9:47










  • is there any way out?
    – Wasila
    Jan 27 '16 at 9:48










  • If your shell supports the if [ "$src" -nt "$dst ]; then … construct you can use that one (however, not it's not in POSIX). Do you have pax or rsync available? That might be the easiest solution.
    – Marco
    Jan 27 '16 at 9:55










  • I haven't tried pax yet. But I am unable to install rsync on my solaris system
    – Wasila
    Jan 27 '16 at 10:00










  • "cp" on Linux is usually from the GNU coreutils which are also available for Solaris - can you build & install software like that on your Solaris machine or are your privileges limited?
    – alanc
    Jan 27 '16 at 16:37













up vote
3
down vote

favorite









up vote
3
down vote

favorite











I want to copy only when the SOURCE file is newer than the destination file or when the destination file is missing. As you know, this feature will work on Linux system on following command.



cp -u /source/*.txt /destination/  


but when i am using this command on solaris system 10. Below is my outut:



cp: illegal option -- u
Usage: cp [-f] [-i] [-p] [-@] f1 f2
cp [-f] [-i] [-p] [-@] f1 ... fn d1
cp -r|-R [-H|-L|-P] [-f] [-i] [-p] [-@] d1 ... dn-1 dn


Is there any solution?










share|improve this question















I want to copy only when the SOURCE file is newer than the destination file or when the destination file is missing. As you know, this feature will work on Linux system on following command.



cp -u /source/*.txt /destination/  


but when i am using this command on solaris system 10. Below is my outut:



cp: illegal option -- u
Usage: cp [-f] [-i] [-p] [-@] f1 f2
cp [-f] [-i] [-p] [-@] f1 ... fn d1
cp -r|-R [-H|-L|-P] [-f] [-i] [-p] [-@] d1 ... dn-1 dn


Is there any solution?







solaris cp






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 25 at 22:29









Rui F Ribeiro

38.3k1477127




38.3k1477127










asked Jan 27 '16 at 9:41









Wasila

68118




68118












  • Don't think you can.
    – 123
    Jan 27 '16 at 9:47










  • is there any way out?
    – Wasila
    Jan 27 '16 at 9:48










  • If your shell supports the if [ "$src" -nt "$dst ]; then … construct you can use that one (however, not it's not in POSIX). Do you have pax or rsync available? That might be the easiest solution.
    – Marco
    Jan 27 '16 at 9:55










  • I haven't tried pax yet. But I am unable to install rsync on my solaris system
    – Wasila
    Jan 27 '16 at 10:00










  • "cp" on Linux is usually from the GNU coreutils which are also available for Solaris - can you build & install software like that on your Solaris machine or are your privileges limited?
    – alanc
    Jan 27 '16 at 16:37


















  • Don't think you can.
    – 123
    Jan 27 '16 at 9:47










  • is there any way out?
    – Wasila
    Jan 27 '16 at 9:48










  • If your shell supports the if [ "$src" -nt "$dst ]; then … construct you can use that one (however, not it's not in POSIX). Do you have pax or rsync available? That might be the easiest solution.
    – Marco
    Jan 27 '16 at 9:55










  • I haven't tried pax yet. But I am unable to install rsync on my solaris system
    – Wasila
    Jan 27 '16 at 10:00










  • "cp" on Linux is usually from the GNU coreutils which are also available for Solaris - can you build & install software like that on your Solaris machine or are your privileges limited?
    – alanc
    Jan 27 '16 at 16:37
















Don't think you can.
– 123
Jan 27 '16 at 9:47




Don't think you can.
– 123
Jan 27 '16 at 9:47












is there any way out?
– Wasila
Jan 27 '16 at 9:48




is there any way out?
– Wasila
Jan 27 '16 at 9:48












If your shell supports the if [ "$src" -nt "$dst ]; then … construct you can use that one (however, not it's not in POSIX). Do you have pax or rsync available? That might be the easiest solution.
– Marco
Jan 27 '16 at 9:55




If your shell supports the if [ "$src" -nt "$dst ]; then … construct you can use that one (however, not it's not in POSIX). Do you have pax or rsync available? That might be the easiest solution.
– Marco
Jan 27 '16 at 9:55












I haven't tried pax yet. But I am unable to install rsync on my solaris system
– Wasila
Jan 27 '16 at 10:00




I haven't tried pax yet. But I am unable to install rsync on my solaris system
– Wasila
Jan 27 '16 at 10:00












"cp" on Linux is usually from the GNU coreutils which are also available for Solaris - can you build & install software like that on your Solaris machine or are your privileges limited?
– alanc
Jan 27 '16 at 16:37




"cp" on Linux is usually from the GNU coreutils which are also available for Solaris - can you build & install software like that on your Solaris machine or are your privileges limited?
– alanc
Jan 27 '16 at 16:37










3 Answers
3






active

oldest

votes

















up vote
2
down vote



accepted










You might use rsync -u which provides the same functionality. It is available on the current Solaris release (11.x) and also in the last Solaris 10 one (Oracle Solaris 10 1/13).



The source code of the Solaris 10 one is included in the full open source code bundle downloadable from here (beware that it's a 1 GB file).






share|improve this answer























  • I am facing problem installing RSYNC Solaris 10. I have asked another question about the procedure. Subject line: RSYNC installation procedure on Solaris 10. any other solution rather than RSYNC/ CP -u?
    – Wasila
    Jan 27 '16 at 9:55












  • Thanks jilliagre. I will let you know if your link solve my problem.
    – Wasila
    Jan 28 '16 at 3:05










  • Beware recompiling is the hard way if you aren't familiar doing it. I would suggest you to consider Gilles' answer as it doesn't require any new software installation.
    – jlliagre
    Jan 28 '16 at 3:10










  • Ok sure jilliagre. I will go with Gilles solution.
    – Wasila
    Jan 28 '16 at 3:30


















up vote
3
down vote













cp -u is a feature of GNU coreutils, which is the standard on non-embedded Linux but not on Solaris.



On Solaris or any other POSIX-compliant system¹, you can use pax, which has similar functionality. The pax command is POSIX's replacement for the historical cpio and tar commands; in its pass-through mode, it's similar to cp -R. The -u option is similar to that of GNU cp (they both took it from historical archivers such as tar and ar).



cd /source
pax -rw -u *.txt /destination


(Not pax -rw -u /source/*.txt /destination, because that would create /destination/source/file.txt)



¹ Beware that many Linux distributions omit pax from the default installation. It's always available as a package however.






share|improve this answer























  • Thanks Gilles. It works. cd /source pax -rw -u *.txt /destination
    – Wasila
    Jan 28 '16 at 3:02


















up vote
0
down vote













You are on a rather old Solaris there. Anyways as others have pointed out the -u option is something 'invented' in GNU, so you would have to use the GNU version of cp. This is done by installing GNU coreutils and then explicitly referencing gcp on your command line. Your example would become



gcp -u /source/*.txt /destination/


How this can be installed can be found here, but if your SysAdm had done his job it would have been there already (that's just my personal opinion :-))






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f257957%2fhow-to-use-cp-u-on-a-solaris-system-which-does-not-support-the-u-option%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote



    accepted










    You might use rsync -u which provides the same functionality. It is available on the current Solaris release (11.x) and also in the last Solaris 10 one (Oracle Solaris 10 1/13).



    The source code of the Solaris 10 one is included in the full open source code bundle downloadable from here (beware that it's a 1 GB file).






    share|improve this answer























    • I am facing problem installing RSYNC Solaris 10. I have asked another question about the procedure. Subject line: RSYNC installation procedure on Solaris 10. any other solution rather than RSYNC/ CP -u?
      – Wasila
      Jan 27 '16 at 9:55












    • Thanks jilliagre. I will let you know if your link solve my problem.
      – Wasila
      Jan 28 '16 at 3:05










    • Beware recompiling is the hard way if you aren't familiar doing it. I would suggest you to consider Gilles' answer as it doesn't require any new software installation.
      – jlliagre
      Jan 28 '16 at 3:10










    • Ok sure jilliagre. I will go with Gilles solution.
      – Wasila
      Jan 28 '16 at 3:30















    up vote
    2
    down vote



    accepted










    You might use rsync -u which provides the same functionality. It is available on the current Solaris release (11.x) and also in the last Solaris 10 one (Oracle Solaris 10 1/13).



    The source code of the Solaris 10 one is included in the full open source code bundle downloadable from here (beware that it's a 1 GB file).






    share|improve this answer























    • I am facing problem installing RSYNC Solaris 10. I have asked another question about the procedure. Subject line: RSYNC installation procedure on Solaris 10. any other solution rather than RSYNC/ CP -u?
      – Wasila
      Jan 27 '16 at 9:55












    • Thanks jilliagre. I will let you know if your link solve my problem.
      – Wasila
      Jan 28 '16 at 3:05










    • Beware recompiling is the hard way if you aren't familiar doing it. I would suggest you to consider Gilles' answer as it doesn't require any new software installation.
      – jlliagre
      Jan 28 '16 at 3:10










    • Ok sure jilliagre. I will go with Gilles solution.
      – Wasila
      Jan 28 '16 at 3:30













    up vote
    2
    down vote



    accepted







    up vote
    2
    down vote



    accepted






    You might use rsync -u which provides the same functionality. It is available on the current Solaris release (11.x) and also in the last Solaris 10 one (Oracle Solaris 10 1/13).



    The source code of the Solaris 10 one is included in the full open source code bundle downloadable from here (beware that it's a 1 GB file).






    share|improve this answer














    You might use rsync -u which provides the same functionality. It is available on the current Solaris release (11.x) and also in the last Solaris 10 one (Oracle Solaris 10 1/13).



    The source code of the Solaris 10 one is included in the full open source code bundle downloadable from here (beware that it's a 1 GB file).







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jan 28 '16 at 1:27

























    answered Jan 27 '16 at 9:52









    jlliagre

    46.1k783132




    46.1k783132












    • I am facing problem installing RSYNC Solaris 10. I have asked another question about the procedure. Subject line: RSYNC installation procedure on Solaris 10. any other solution rather than RSYNC/ CP -u?
      – Wasila
      Jan 27 '16 at 9:55












    • Thanks jilliagre. I will let you know if your link solve my problem.
      – Wasila
      Jan 28 '16 at 3:05










    • Beware recompiling is the hard way if you aren't familiar doing it. I would suggest you to consider Gilles' answer as it doesn't require any new software installation.
      – jlliagre
      Jan 28 '16 at 3:10










    • Ok sure jilliagre. I will go with Gilles solution.
      – Wasila
      Jan 28 '16 at 3:30


















    • I am facing problem installing RSYNC Solaris 10. I have asked another question about the procedure. Subject line: RSYNC installation procedure on Solaris 10. any other solution rather than RSYNC/ CP -u?
      – Wasila
      Jan 27 '16 at 9:55












    • Thanks jilliagre. I will let you know if your link solve my problem.
      – Wasila
      Jan 28 '16 at 3:05










    • Beware recompiling is the hard way if you aren't familiar doing it. I would suggest you to consider Gilles' answer as it doesn't require any new software installation.
      – jlliagre
      Jan 28 '16 at 3:10










    • Ok sure jilliagre. I will go with Gilles solution.
      – Wasila
      Jan 28 '16 at 3:30
















    I am facing problem installing RSYNC Solaris 10. I have asked another question about the procedure. Subject line: RSYNC installation procedure on Solaris 10. any other solution rather than RSYNC/ CP -u?
    – Wasila
    Jan 27 '16 at 9:55






    I am facing problem installing RSYNC Solaris 10. I have asked another question about the procedure. Subject line: RSYNC installation procedure on Solaris 10. any other solution rather than RSYNC/ CP -u?
    – Wasila
    Jan 27 '16 at 9:55














    Thanks jilliagre. I will let you know if your link solve my problem.
    – Wasila
    Jan 28 '16 at 3:05




    Thanks jilliagre. I will let you know if your link solve my problem.
    – Wasila
    Jan 28 '16 at 3:05












    Beware recompiling is the hard way if you aren't familiar doing it. I would suggest you to consider Gilles' answer as it doesn't require any new software installation.
    – jlliagre
    Jan 28 '16 at 3:10




    Beware recompiling is the hard way if you aren't familiar doing it. I would suggest you to consider Gilles' answer as it doesn't require any new software installation.
    – jlliagre
    Jan 28 '16 at 3:10












    Ok sure jilliagre. I will go with Gilles solution.
    – Wasila
    Jan 28 '16 at 3:30




    Ok sure jilliagre. I will go with Gilles solution.
    – Wasila
    Jan 28 '16 at 3:30












    up vote
    3
    down vote













    cp -u is a feature of GNU coreutils, which is the standard on non-embedded Linux but not on Solaris.



    On Solaris or any other POSIX-compliant system¹, you can use pax, which has similar functionality. The pax command is POSIX's replacement for the historical cpio and tar commands; in its pass-through mode, it's similar to cp -R. The -u option is similar to that of GNU cp (they both took it from historical archivers such as tar and ar).



    cd /source
    pax -rw -u *.txt /destination


    (Not pax -rw -u /source/*.txt /destination, because that would create /destination/source/file.txt)



    ¹ Beware that many Linux distributions omit pax from the default installation. It's always available as a package however.






    share|improve this answer























    • Thanks Gilles. It works. cd /source pax -rw -u *.txt /destination
      – Wasila
      Jan 28 '16 at 3:02















    up vote
    3
    down vote













    cp -u is a feature of GNU coreutils, which is the standard on non-embedded Linux but not on Solaris.



    On Solaris or any other POSIX-compliant system¹, you can use pax, which has similar functionality. The pax command is POSIX's replacement for the historical cpio and tar commands; in its pass-through mode, it's similar to cp -R. The -u option is similar to that of GNU cp (they both took it from historical archivers such as tar and ar).



    cd /source
    pax -rw -u *.txt /destination


    (Not pax -rw -u /source/*.txt /destination, because that would create /destination/source/file.txt)



    ¹ Beware that many Linux distributions omit pax from the default installation. It's always available as a package however.






    share|improve this answer























    • Thanks Gilles. It works. cd /source pax -rw -u *.txt /destination
      – Wasila
      Jan 28 '16 at 3:02













    up vote
    3
    down vote










    up vote
    3
    down vote









    cp -u is a feature of GNU coreutils, which is the standard on non-embedded Linux but not on Solaris.



    On Solaris or any other POSIX-compliant system¹, you can use pax, which has similar functionality. The pax command is POSIX's replacement for the historical cpio and tar commands; in its pass-through mode, it's similar to cp -R. The -u option is similar to that of GNU cp (they both took it from historical archivers such as tar and ar).



    cd /source
    pax -rw -u *.txt /destination


    (Not pax -rw -u /source/*.txt /destination, because that would create /destination/source/file.txt)



    ¹ Beware that many Linux distributions omit pax from the default installation. It's always available as a package however.






    share|improve this answer














    cp -u is a feature of GNU coreutils, which is the standard on non-embedded Linux but not on Solaris.



    On Solaris or any other POSIX-compliant system¹, you can use pax, which has similar functionality. The pax command is POSIX's replacement for the historical cpio and tar commands; in its pass-through mode, it's similar to cp -R. The -u option is similar to that of GNU cp (they both took it from historical archivers such as tar and ar).



    cd /source
    pax -rw -u *.txt /destination


    (Not pax -rw -u /source/*.txt /destination, because that would create /destination/source/file.txt)



    ¹ Beware that many Linux distributions omit pax from the default installation. It's always available as a package however.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jan 28 '16 at 1:27









    jlliagre

    46.1k783132




    46.1k783132










    answered Jan 27 '16 at 23:42









    Gilles

    523k12610441576




    523k12610441576












    • Thanks Gilles. It works. cd /source pax -rw -u *.txt /destination
      – Wasila
      Jan 28 '16 at 3:02


















    • Thanks Gilles. It works. cd /source pax -rw -u *.txt /destination
      – Wasila
      Jan 28 '16 at 3:02
















    Thanks Gilles. It works. cd /source pax -rw -u *.txt /destination
    – Wasila
    Jan 28 '16 at 3:02




    Thanks Gilles. It works. cd /source pax -rw -u *.txt /destination
    – Wasila
    Jan 28 '16 at 3:02










    up vote
    0
    down vote













    You are on a rather old Solaris there. Anyways as others have pointed out the -u option is something 'invented' in GNU, so you would have to use the GNU version of cp. This is done by installing GNU coreutils and then explicitly referencing gcp on your command line. Your example would become



    gcp -u /source/*.txt /destination/


    How this can be installed can be found here, but if your SysAdm had done his job it would have been there already (that's just my personal opinion :-))






    share|improve this answer



























      up vote
      0
      down vote













      You are on a rather old Solaris there. Anyways as others have pointed out the -u option is something 'invented' in GNU, so you would have to use the GNU version of cp. This is done by installing GNU coreutils and then explicitly referencing gcp on your command line. Your example would become



      gcp -u /source/*.txt /destination/


      How this can be installed can be found here, but if your SysAdm had done his job it would have been there already (that's just my personal opinion :-))






      share|improve this answer

























        up vote
        0
        down vote










        up vote
        0
        down vote









        You are on a rather old Solaris there. Anyways as others have pointed out the -u option is something 'invented' in GNU, so you would have to use the GNU version of cp. This is done by installing GNU coreutils and then explicitly referencing gcp on your command line. Your example would become



        gcp -u /source/*.txt /destination/


        How this can be installed can be found here, but if your SysAdm had done his job it would have been there already (that's just my personal opinion :-))






        share|improve this answer














        You are on a rather old Solaris there. Anyways as others have pointed out the -u option is something 'invented' in GNU, so you would have to use the GNU version of cp. This is done by installing GNU coreutils and then explicitly referencing gcp on your command line. Your example would become



        gcp -u /source/*.txt /destination/


        How this can be installed can be found here, but if your SysAdm had done his job it would have been there already (that's just my personal opinion :-))







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Apr 13 '17 at 12:36









        Community

        1




        1










        answered Feb 20 '16 at 10:38









        peterh

        7191614




        7191614






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f257957%2fhow-to-use-cp-u-on-a-solaris-system-which-does-not-support-the-u-option%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Morgemoulin

            Scott Moir

            Souastre