prepending a command to the output of a pipe
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
The following command:
jq ". | .file.url_private_download" *json
generates many lines in the form of:
"https://files.slack.com/files-pri/T27SFGS2W-F78LH1DN2/download/img_1964.jpg?t=xoxe-243624297126-248125875671-248125975751-cee1f8d9a1"
What is the simplest way to prepend a wget command in front of each of these lines ?
Thank you very much
shell terminal pipe
add a comment |Â
up vote
0
down vote
favorite
The following command:
jq ". | .file.url_private_download" *json
generates many lines in the form of:
"https://files.slack.com/files-pri/T27SFGS2W-F78LH1DN2/download/img_1964.jpg?t=xoxe-243624297126-248125875671-248125975751-cee1f8d9a1"
What is the simplest way to prepend a wget command in front of each of these lines ?
Thank you very much
shell terminal pipe
Do you want to execute the command or just prepend it with the string?
â Kusalananda
Sep 26 '17 at 17:10
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
The following command:
jq ". | .file.url_private_download" *json
generates many lines in the form of:
"https://files.slack.com/files-pri/T27SFGS2W-F78LH1DN2/download/img_1964.jpg?t=xoxe-243624297126-248125875671-248125975751-cee1f8d9a1"
What is the simplest way to prepend a wget command in front of each of these lines ?
Thank you very much
shell terminal pipe
The following command:
jq ". | .file.url_private_download" *json
generates many lines in the form of:
"https://files.slack.com/files-pri/T27SFGS2W-F78LH1DN2/download/img_1964.jpg?t=xoxe-243624297126-248125875671-248125975751-cee1f8d9a1"
What is the simplest way to prepend a wget command in front of each of these lines ?
Thank you very much
shell terminal pipe
shell terminal pipe
edited Sep 26 '17 at 17:06
Satà  Katsura
10.7k11533
10.7k11533
asked Sep 26 '17 at 17:01
Robert Alexander
494
494
Do you want to execute the command or just prepend it with the string?
â Kusalananda
Sep 26 '17 at 17:10
add a comment |Â
Do you want to execute the command or just prepend it with the string?
â Kusalananda
Sep 26 '17 at 17:10
Do you want to execute the command or just prepend it with the string?
â Kusalananda
Sep 26 '17 at 17:10
Do you want to execute the command or just prepend it with the string?
â Kusalananda
Sep 26 '17 at 17:10
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
1
down vote
You could use xargs
to prepend the command you want to each line:
jq ". | .file.url_private_download" *json | xargs -n1 /bin/echo "wget"
thank you, btw wget has an option to read URLs from a file (but curl on my Mac does not AFAIK)
â Robert Alexander
Sep 28 '17 at 8:13
add a comment |Â
up vote
1
down vote
You could use sed
to rewrite the start of each line:
jq ". | .file.url_private_download" *json | sed 's/^/wget /'
which "replaces" the start of the line with whatever the replacement pattern is, here wget
Or to wget
all the files:
jq ". | .file.url_private_download" *json | wget -i -
thank you, btw wget has an option to read URLs from a file (but curl on my Mac does not AFAIK)
â Robert Alexander
Sep 28 '17 at 8:13
@RobertAlexander right, isn't that what my second option uses?
â Eric Renouf
Sep 28 '17 at 10:10
Yes it is just what you indicated in your second example. Thank you.
â Robert Alexander
Sep 29 '17 at 12:46
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
You could use xargs
to prepend the command you want to each line:
jq ". | .file.url_private_download" *json | xargs -n1 /bin/echo "wget"
thank you, btw wget has an option to read URLs from a file (but curl on my Mac does not AFAIK)
â Robert Alexander
Sep 28 '17 at 8:13
add a comment |Â
up vote
1
down vote
You could use xargs
to prepend the command you want to each line:
jq ". | .file.url_private_download" *json | xargs -n1 /bin/echo "wget"
thank you, btw wget has an option to read URLs from a file (but curl on my Mac does not AFAIK)
â Robert Alexander
Sep 28 '17 at 8:13
add a comment |Â
up vote
1
down vote
up vote
1
down vote
You could use xargs
to prepend the command you want to each line:
jq ". | .file.url_private_download" *json | xargs -n1 /bin/echo "wget"
You could use xargs
to prepend the command you want to each line:
jq ". | .file.url_private_download" *json | xargs -n1 /bin/echo "wget"
answered Sep 26 '17 at 17:23
JRFerguson
9,17532329
9,17532329
thank you, btw wget has an option to read URLs from a file (but curl on my Mac does not AFAIK)
â Robert Alexander
Sep 28 '17 at 8:13
add a comment |Â
thank you, btw wget has an option to read URLs from a file (but curl on my Mac does not AFAIK)
â Robert Alexander
Sep 28 '17 at 8:13
thank you, btw wget has an option to read URLs from a file (but curl on my Mac does not AFAIK)
â Robert Alexander
Sep 28 '17 at 8:13
thank you, btw wget has an option to read URLs from a file (but curl on my Mac does not AFAIK)
â Robert Alexander
Sep 28 '17 at 8:13
add a comment |Â
up vote
1
down vote
You could use sed
to rewrite the start of each line:
jq ". | .file.url_private_download" *json | sed 's/^/wget /'
which "replaces" the start of the line with whatever the replacement pattern is, here wget
Or to wget
all the files:
jq ". | .file.url_private_download" *json | wget -i -
thank you, btw wget has an option to read URLs from a file (but curl on my Mac does not AFAIK)
â Robert Alexander
Sep 28 '17 at 8:13
@RobertAlexander right, isn't that what my second option uses?
â Eric Renouf
Sep 28 '17 at 10:10
Yes it is just what you indicated in your second example. Thank you.
â Robert Alexander
Sep 29 '17 at 12:46
add a comment |Â
up vote
1
down vote
You could use sed
to rewrite the start of each line:
jq ". | .file.url_private_download" *json | sed 's/^/wget /'
which "replaces" the start of the line with whatever the replacement pattern is, here wget
Or to wget
all the files:
jq ". | .file.url_private_download" *json | wget -i -
thank you, btw wget has an option to read URLs from a file (but curl on my Mac does not AFAIK)
â Robert Alexander
Sep 28 '17 at 8:13
@RobertAlexander right, isn't that what my second option uses?
â Eric Renouf
Sep 28 '17 at 10:10
Yes it is just what you indicated in your second example. Thank you.
â Robert Alexander
Sep 29 '17 at 12:46
add a comment |Â
up vote
1
down vote
up vote
1
down vote
You could use sed
to rewrite the start of each line:
jq ". | .file.url_private_download" *json | sed 's/^/wget /'
which "replaces" the start of the line with whatever the replacement pattern is, here wget
Or to wget
all the files:
jq ". | .file.url_private_download" *json | wget -i -
You could use sed
to rewrite the start of each line:
jq ". | .file.url_private_download" *json | sed 's/^/wget /'
which "replaces" the start of the line with whatever the replacement pattern is, here wget
Or to wget
all the files:
jq ". | .file.url_private_download" *json | wget -i -
edited Sep 26 '17 at 18:29
answered Sep 26 '17 at 17:09
Eric Renouf
12.9k42949
12.9k42949
thank you, btw wget has an option to read URLs from a file (but curl on my Mac does not AFAIK)
â Robert Alexander
Sep 28 '17 at 8:13
@RobertAlexander right, isn't that what my second option uses?
â Eric Renouf
Sep 28 '17 at 10:10
Yes it is just what you indicated in your second example. Thank you.
â Robert Alexander
Sep 29 '17 at 12:46
add a comment |Â
thank you, btw wget has an option to read URLs from a file (but curl on my Mac does not AFAIK)
â Robert Alexander
Sep 28 '17 at 8:13
@RobertAlexander right, isn't that what my second option uses?
â Eric Renouf
Sep 28 '17 at 10:10
Yes it is just what you indicated in your second example. Thank you.
â Robert Alexander
Sep 29 '17 at 12:46
thank you, btw wget has an option to read URLs from a file (but curl on my Mac does not AFAIK)
â Robert Alexander
Sep 28 '17 at 8:13
thank you, btw wget has an option to read URLs from a file (but curl on my Mac does not AFAIK)
â Robert Alexander
Sep 28 '17 at 8:13
@RobertAlexander right, isn't that what my second option uses?
â Eric Renouf
Sep 28 '17 at 10:10
@RobertAlexander right, isn't that what my second option uses?
â Eric Renouf
Sep 28 '17 at 10:10
Yes it is just what you indicated in your second example. Thank you.
â Robert Alexander
Sep 29 '17 at 12:46
Yes it is just what you indicated in your second example. Thank you.
â Robert Alexander
Sep 29 '17 at 12:46
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%2f394585%2fprepending-a-command-to-the-output-of-a-pipe%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
Do you want to execute the command or just prepend it with the string?
â Kusalananda
Sep 26 '17 at 17:10