Specify pipe output position
Clash 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?
linux bash pipe
add a comment |Â
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?
linux bash pipe
Is there any purpose with your command that thisrsync -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 meanmyserver:~/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 inrsync
?! 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
add a comment |Â
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?
linux bash pipe
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?
linux bash pipe
asked Oct 21 '17 at 7:39
Lumify
1217
1217
Is there any purpose with your command that thisrsync -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 meanmyserver:~/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 inrsync
?! 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
add a comment |Â
Is there any purpose with your command that thisrsync -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 meanmyserver:~/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 inrsync
?! 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
add a comment |Â
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/
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
add a comment |Â
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 ($()
).
add a comment |Â
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.
add a comment |Â
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/
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
add a comment |Â
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/
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
add a comment |Â
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/
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/
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
add a comment |Â
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
add a comment |Â
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 ($()
).
add a comment |Â
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 ($()
).
add a comment |Â
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 ($()
).
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 ($()
).
answered Oct 21 '17 at 8:52
PSkocik
17.2k24589
17.2k24589
add a comment |Â
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
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.
edited Oct 21 '17 at 10:40
answered Oct 21 '17 at 8:46
Kusalananda
105k14209326
105k14209326
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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 inrsync
?! 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