prepending a command to the output of a pipe

The name of the pictureThe name of the pictureThe name of the pictureClash 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










share|improve this question























  • Do you want to execute the command or just prepend it with the string?
    – Kusalananda
    Sep 26 '17 at 17:10














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










share|improve this question























  • Do you want to execute the command or just prepend it with the string?
    – Kusalananda
    Sep 26 '17 at 17:10












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










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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
















  • 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










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" 





share|improve this answer




















  • 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

















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 -





share|improve this answer






















  • 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










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%2f394585%2fprepending-a-command-to-the-output-of-a-pipe%23new-answer', 'question_page');

);

Post as a guest






























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" 





share|improve this answer




















  • 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














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" 





share|improve this answer




















  • 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












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" 





share|improve this answer












You could use xargs to prepend the command you want to each line:



jq ". | .file.url_private_download" *json | xargs -n1 /bin/echo "wget" 






share|improve this answer












share|improve this answer



share|improve this answer










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
















  • 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












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 -





share|improve this answer






















  • 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














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 -





share|improve this answer






















  • 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












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 -





share|improve this answer














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 -






share|improve this answer














share|improve this answer



share|improve this answer








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
















  • 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

















 

draft saved


draft discarded















































 


draft saved


draft discarded














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













































































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?