Specify pipe output position

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












I want to do stuff like this:



echo myserver:~/dir/2/ | rsync -r HERE /local/path/


I want the output redirected to a specified location in the command. The echo stuff goes "HERE". What's the easiest way to do this?







share|improve this question




















  • Is there any purpose with your command that this rsync -r myserver:~/dir/2/ /local/path/ doesn't prove it?
    – Î±Ò“sнιη
    Oct 21 '17 at 9:25










  • Yes, proof of concept. My real script is long and hard to read, so I made this one.
    – Lumify
    Oct 21 '17 at 9:27










  • Didn't get you mean! You mean myserver:~/dir/2/ resulting from a script as its output and it's /to/ooo/ooo/oooo/looooong/path that you don't want to type in rsync?! Then PSkocik's answer is better choice` (surly I cannot change your choice)
    – Î±Ò“sнιη
    Oct 21 '17 at 9:31











  • Yeah and I have variables that I can't even keep track of anymore.
    – Lumify
    Oct 21 '17 at 9:37














up vote
3
down vote

favorite












I want to do stuff like this:



echo myserver:~/dir/2/ | rsync -r HERE /local/path/


I want the output redirected to a specified location in the command. The echo stuff goes "HERE". What's the easiest way to do this?







share|improve this question




















  • Is there any purpose with your command that this rsync -r myserver:~/dir/2/ /local/path/ doesn't prove it?
    – Î±Ò“sнιη
    Oct 21 '17 at 9:25










  • Yes, proof of concept. My real script is long and hard to read, so I made this one.
    – Lumify
    Oct 21 '17 at 9:27










  • Didn't get you mean! You mean myserver:~/dir/2/ resulting from a script as its output and it's /to/ooo/ooo/oooo/looooong/path that you don't want to type in rsync?! Then PSkocik's answer is better choice` (surly I cannot change your choice)
    – Î±Ò“sнιη
    Oct 21 '17 at 9:31











  • Yeah and I have variables that I can't even keep track of anymore.
    – Lumify
    Oct 21 '17 at 9:37












up vote
3
down vote

favorite









up vote
3
down vote

favorite











I want to do stuff like this:



echo myserver:~/dir/2/ | rsync -r HERE /local/path/


I want the output redirected to a specified location in the command. The echo stuff goes "HERE". What's the easiest way to do this?







share|improve this question












I want to do stuff like this:



echo myserver:~/dir/2/ | rsync -r HERE /local/path/


I want the output redirected to a specified location in the command. The echo stuff goes "HERE". What's the easiest way to do this?









share|improve this question











share|improve this question




share|improve this question










asked Oct 21 '17 at 7:39









Lumify

1217




1217











  • Is there any purpose with your command that this rsync -r myserver:~/dir/2/ /local/path/ doesn't prove it?
    – Î±Ò“sнιη
    Oct 21 '17 at 9:25










  • Yes, proof of concept. My real script is long and hard to read, so I made this one.
    – Lumify
    Oct 21 '17 at 9:27










  • Didn't get you mean! You mean myserver:~/dir/2/ resulting from a script as its output and it's /to/ooo/ooo/oooo/looooong/path that you don't want to type in rsync?! Then PSkocik's answer is better choice` (surly I cannot change your choice)
    – Î±Ò“sнιη
    Oct 21 '17 at 9:31











  • Yeah and I have variables that I can't even keep track of anymore.
    – Lumify
    Oct 21 '17 at 9:37
















  • Is there any purpose with your command that this rsync -r myserver:~/dir/2/ /local/path/ doesn't prove it?
    – Î±Ò“sнιη
    Oct 21 '17 at 9:25










  • Yes, proof of concept. My real script is long and hard to read, so I made this one.
    – Lumify
    Oct 21 '17 at 9:27










  • Didn't get you mean! You mean myserver:~/dir/2/ resulting from a script as its output and it's /to/ooo/ooo/oooo/looooong/path that you don't want to type in rsync?! Then PSkocik's answer is better choice` (surly I cannot change your choice)
    – Î±Ò“sнιη
    Oct 21 '17 at 9:31











  • Yeah and I have variables that I can't even keep track of anymore.
    – Lumify
    Oct 21 '17 at 9:37















Is there any purpose with your command that this rsync -r myserver:~/dir/2/ /local/path/ doesn't prove it?
– Î±Ò“sнιη
Oct 21 '17 at 9:25




Is there any purpose with your command that this rsync -r myserver:~/dir/2/ /local/path/ doesn't prove it?
– Î±Ò“sнιη
Oct 21 '17 at 9:25












Yes, proof of concept. My real script is long and hard to read, so I made this one.
– Lumify
Oct 21 '17 at 9:27




Yes, proof of concept. My real script is long and hard to read, so I made this one.
– Lumify
Oct 21 '17 at 9:27












Didn't get you mean! You mean myserver:~/dir/2/ resulting from a script as its output and it's /to/ooo/ooo/oooo/looooong/path that you don't want to type in rsync?! Then PSkocik's answer is better choice` (surly I cannot change your choice)
– Î±Ò“sнιη
Oct 21 '17 at 9:31





Didn't get you mean! You mean myserver:~/dir/2/ resulting from a script as its output and it's /to/ooo/ooo/oooo/looooong/path that you don't want to type in rsync?! Then PSkocik's answer is better choice` (surly I cannot change your choice)
– Î±Ò“sнιη
Oct 21 '17 at 9:31













Yeah and I have variables that I can't even keep track of anymore.
– Lumify
Oct 21 '17 at 9:37




Yeah and I have variables that I can't even keep track of anymore.
– Lumify
Oct 21 '17 at 9:37










3 Answers
3






active

oldest

votes

















up vote
4
down vote



accepted










You can use xargs or exactly this requirement. You can use the -I as place-holder for the input received from the pipeline, do



echo "myserver:$HOME/dir/2/" | xargs -I rsync -r "" /local/path/


(or) use ~ without double-quotes under which it does not expand to the HOME directory path.



echo myserver:~/dir/2/ | xargs -I rsync -r "" /local/path/





share|improve this answer






















  • xargs seems overkill for something where simple command substitution ($()) will do...
    – marcelm
    Oct 21 '17 at 10:04






  • 1




    @marcelm : Thanks for the feedback. Yes I just wanted to show one of the many options possible to do. It is up to the OP to choose the best option. Am sure it didn’t deserve a -ve vote
    – Inian
    Oct 21 '17 at 10:13

















up vote
7
down vote













This



 rsync -r "$(echo myserver:~/dir/2/)" /local/path/


is the easiest way to do it.



Piping connects stdouts with stdins. Here you want the output to go to an argument, so you need something else than classical piping.



That something is command substitution ($()).






share|improve this answer



























    up vote
    2
    down vote













    You may give rsync a list of files to download in a file or on standard input by using --files-from:



    echo "dir/2/" | rsync --files-from=- -r user@server: /local/path/


    The - makes rsync read from standard input. The server can't be given to rsync in this manner. There will only be a single connection made to the server and all files will be transferred over that connection.



    If you use -a or --archive with --files-from then you need to explicitly add -r or --recursive if you want to recursion since that option, even though it's part of -a, is disabled when --files-from is used.






    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: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      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%2f399492%2fspecify-pipe-output-position%23new-answer', 'question_page');

      );

      Post as a guest






























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      4
      down vote



      accepted










      You can use xargs or exactly this requirement. You can use the -I as place-holder for the input received from the pipeline, do



      echo "myserver:$HOME/dir/2/" | xargs -I rsync -r "" /local/path/


      (or) use ~ without double-quotes under which it does not expand to the HOME directory path.



      echo myserver:~/dir/2/ | xargs -I rsync -r "" /local/path/





      share|improve this answer






















      • xargs seems overkill for something where simple command substitution ($()) will do...
        – marcelm
        Oct 21 '17 at 10:04






      • 1




        @marcelm : Thanks for the feedback. Yes I just wanted to show one of the many options possible to do. It is up to the OP to choose the best option. Am sure it didn’t deserve a -ve vote
        – Inian
        Oct 21 '17 at 10:13














      up vote
      4
      down vote



      accepted










      You can use xargs or exactly this requirement. You can use the -I as place-holder for the input received from the pipeline, do



      echo "myserver:$HOME/dir/2/" | xargs -I rsync -r "" /local/path/


      (or) use ~ without double-quotes under which it does not expand to the HOME directory path.



      echo myserver:~/dir/2/ | xargs -I rsync -r "" /local/path/





      share|improve this answer






















      • xargs seems overkill for something where simple command substitution ($()) will do...
        – marcelm
        Oct 21 '17 at 10:04






      • 1




        @marcelm : Thanks for the feedback. Yes I just wanted to show one of the many options possible to do. It is up to the OP to choose the best option. Am sure it didn’t deserve a -ve vote
        – Inian
        Oct 21 '17 at 10:13












      up vote
      4
      down vote



      accepted







      up vote
      4
      down vote



      accepted






      You can use xargs or exactly this requirement. You can use the -I as place-holder for the input received from the pipeline, do



      echo "myserver:$HOME/dir/2/" | xargs -I rsync -r "" /local/path/


      (or) use ~ without double-quotes under which it does not expand to the HOME directory path.



      echo myserver:~/dir/2/ | xargs -I rsync -r "" /local/path/





      share|improve this answer














      You can use xargs or exactly this requirement. You can use the -I as place-holder for the input received from the pipeline, do



      echo "myserver:$HOME/dir/2/" | xargs -I rsync -r "" /local/path/


      (or) use ~ without double-quotes under which it does not expand to the HOME directory path.



      echo myserver:~/dir/2/ | xargs -I rsync -r "" /local/path/






      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Oct 21 '17 at 7:47

























      answered Oct 21 '17 at 7:42









      Inian

      2,855822




      2,855822











      • xargs seems overkill for something where simple command substitution ($()) will do...
        – marcelm
        Oct 21 '17 at 10:04






      • 1




        @marcelm : Thanks for the feedback. Yes I just wanted to show one of the many options possible to do. It is up to the OP to choose the best option. Am sure it didn’t deserve a -ve vote
        – Inian
        Oct 21 '17 at 10:13
















      • xargs seems overkill for something where simple command substitution ($()) will do...
        – marcelm
        Oct 21 '17 at 10:04






      • 1




        @marcelm : Thanks for the feedback. Yes I just wanted to show one of the many options possible to do. It is up to the OP to choose the best option. Am sure it didn’t deserve a -ve vote
        – Inian
        Oct 21 '17 at 10:13















      xargs seems overkill for something where simple command substitution ($()) will do...
      – marcelm
      Oct 21 '17 at 10:04




      xargs seems overkill for something where simple command substitution ($()) will do...
      – marcelm
      Oct 21 '17 at 10:04




      1




      1




      @marcelm : Thanks for the feedback. Yes I just wanted to show one of the many options possible to do. It is up to the OP to choose the best option. Am sure it didn’t deserve a -ve vote
      – Inian
      Oct 21 '17 at 10:13




      @marcelm : Thanks for the feedback. Yes I just wanted to show one of the many options possible to do. It is up to the OP to choose the best option. Am sure it didn’t deserve a -ve vote
      – Inian
      Oct 21 '17 at 10:13












      up vote
      7
      down vote













      This



       rsync -r "$(echo myserver:~/dir/2/)" /local/path/


      is the easiest way to do it.



      Piping connects stdouts with stdins. Here you want the output to go to an argument, so you need something else than classical piping.



      That something is command substitution ($()).






      share|improve this answer
























        up vote
        7
        down vote













        This



         rsync -r "$(echo myserver:~/dir/2/)" /local/path/


        is the easiest way to do it.



        Piping connects stdouts with stdins. Here you want the output to go to an argument, so you need something else than classical piping.



        That something is command substitution ($()).






        share|improve this answer






















          up vote
          7
          down vote










          up vote
          7
          down vote









          This



           rsync -r "$(echo myserver:~/dir/2/)" /local/path/


          is the easiest way to do it.



          Piping connects stdouts with stdins. Here you want the output to go to an argument, so you need something else than classical piping.



          That something is command substitution ($()).






          share|improve this answer












          This



           rsync -r "$(echo myserver:~/dir/2/)" /local/path/


          is the easiest way to do it.



          Piping connects stdouts with stdins. Here you want the output to go to an argument, so you need something else than classical piping.



          That something is command substitution ($()).







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Oct 21 '17 at 8:52









          PSkocik

          17.2k24589




          17.2k24589




















              up vote
              2
              down vote













              You may give rsync a list of files to download in a file or on standard input by using --files-from:



              echo "dir/2/" | rsync --files-from=- -r user@server: /local/path/


              The - makes rsync read from standard input. The server can't be given to rsync in this manner. There will only be a single connection made to the server and all files will be transferred over that connection.



              If you use -a or --archive with --files-from then you need to explicitly add -r or --recursive if you want to recursion since that option, even though it's part of -a, is disabled when --files-from is used.






              share|improve this answer


























                up vote
                2
                down vote













                You may give rsync a list of files to download in a file or on standard input by using --files-from:



                echo "dir/2/" | rsync --files-from=- -r user@server: /local/path/


                The - makes rsync read from standard input. The server can't be given to rsync in this manner. There will only be a single connection made to the server and all files will be transferred over that connection.



                If you use -a or --archive with --files-from then you need to explicitly add -r or --recursive if you want to recursion since that option, even though it's part of -a, is disabled when --files-from is used.






                share|improve this answer
























                  up vote
                  2
                  down vote










                  up vote
                  2
                  down vote









                  You may give rsync a list of files to download in a file or on standard input by using --files-from:



                  echo "dir/2/" | rsync --files-from=- -r user@server: /local/path/


                  The - makes rsync read from standard input. The server can't be given to rsync in this manner. There will only be a single connection made to the server and all files will be transferred over that connection.



                  If you use -a or --archive with --files-from then you need to explicitly add -r or --recursive if you want to recursion since that option, even though it's part of -a, is disabled when --files-from is used.






                  share|improve this answer














                  You may give rsync a list of files to download in a file or on standard input by using --files-from:



                  echo "dir/2/" | rsync --files-from=- -r user@server: /local/path/


                  The - makes rsync read from standard input. The server can't be given to rsync in this manner. There will only be a single connection made to the server and all files will be transferred over that connection.



                  If you use -a or --archive with --files-from then you need to explicitly add -r or --recursive if you want to recursion since that option, even though it's part of -a, is disabled when --files-from is used.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Oct 21 '17 at 10:40

























                  answered Oct 21 '17 at 8:46









                  Kusalananda

                  105k14209326




                  105k14209326



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f399492%2fspecify-pipe-output-position%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      Displaying single band from multi-band raster using QGIS

                      How many registers does an x86_64 CPU actually have?