Uniting urls for a download utility (like wget) in one line
Clash Royale CLAN TAG#URR8PPP
up vote
4
down vote
favorite
Consider these wget
codes:
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/nixta.sh
Is there any elegant way to unite different terminals of the same basic URL as above, into one line instead 2 or more?
Pseudocode:
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh||nixta.sh
command-line wget curl download
add a comment |Â
up vote
4
down vote
favorite
Consider these wget
codes:
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/nixta.sh
Is there any elegant way to unite different terminals of the same basic URL as above, into one line instead 2 or more?
Pseudocode:
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh||nixta.sh
command-line wget curl download
add a comment |Â
up vote
4
down vote
favorite
up vote
4
down vote
favorite
Consider these wget
codes:
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/nixta.sh
Is there any elegant way to unite different terminals of the same basic URL as above, into one line instead 2 or more?
Pseudocode:
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh||nixta.sh
command-line wget curl download
Consider these wget
codes:
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/nixta.sh
Is there any elegant way to unite different terminals of the same basic URL as above, into one line instead 2 or more?
Pseudocode:
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh||nixta.sh
command-line wget curl download
edited Jan 14 at 5:51
asked Jan 13 at 19:51
Arcticooling
83123
83123
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
8
down vote
accepted
As wget
accepts several URLs at once this can be done using brace expansion in bash
:
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh,nixta.sh
(or even
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj,nixta.sh
but this only works for well-suited names of course).
Thanks, allow me to ask, off label - would you consider this a best practice or something commonly done by professional Bash programmers? (at least, the first option which should be with less confusing).
â Arcticooling
Jan 13 at 20:00
1
@Arcticooling Hmm, good question. For URLs it may not make a lot of sense because it prevents easy copy/paste in case you need to access the same file in the browser, I probably wouldn't use it at least. wiki.bash-hackers.org/syntax/expansion/brace says "it's used to generate mass-arguments for a command, that follow a specific naming-scheme.", linuxg.net/⦠has some good examples, I use thecp /path/to/file,.bak
thing regularly (but mostly interactively, not in scripts).
â nohillside
Jan 13 at 20:07
"this only works for well-suited names" â What names do you think it would not work for?
â Hauke Laging
Jan 13 at 20:24
1
@HaukeLaging the second option, which uses brace expansion only for part of the file name, requires file names ending in a common part.
â nohillside
Jan 13 at 21:19
@patrix It makes a lot of sense for URLs; very useful. Oftentimes, a gallery of images on a webpage will have the different image urls differ only by a consecutive number, and so you can dowget http://example.com/img-1..70.jpg
or similar to download them all.
â JoL
Jan 14 at 5:11
 |Â
show 1 more comment
up vote
0
down vote
I have done this by using awk command and for loop. Let me know for any doubts and confusion
Created one file example.txt by putting below content in a file
cat example.txt
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/
I have assigned papj.sh nixta.sh to the variable i
Used below script to execute as per your requirement
for i in papj.sh nixta.sh; do awk -v i="$i" 'print $0i' example.txt; done
Output
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/nixta.sh
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
8
down vote
accepted
As wget
accepts several URLs at once this can be done using brace expansion in bash
:
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh,nixta.sh
(or even
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj,nixta.sh
but this only works for well-suited names of course).
Thanks, allow me to ask, off label - would you consider this a best practice or something commonly done by professional Bash programmers? (at least, the first option which should be with less confusing).
â Arcticooling
Jan 13 at 20:00
1
@Arcticooling Hmm, good question. For URLs it may not make a lot of sense because it prevents easy copy/paste in case you need to access the same file in the browser, I probably wouldn't use it at least. wiki.bash-hackers.org/syntax/expansion/brace says "it's used to generate mass-arguments for a command, that follow a specific naming-scheme.", linuxg.net/⦠has some good examples, I use thecp /path/to/file,.bak
thing regularly (but mostly interactively, not in scripts).
â nohillside
Jan 13 at 20:07
"this only works for well-suited names" â What names do you think it would not work for?
â Hauke Laging
Jan 13 at 20:24
1
@HaukeLaging the second option, which uses brace expansion only for part of the file name, requires file names ending in a common part.
â nohillside
Jan 13 at 21:19
@patrix It makes a lot of sense for URLs; very useful. Oftentimes, a gallery of images on a webpage will have the different image urls differ only by a consecutive number, and so you can dowget http://example.com/img-1..70.jpg
or similar to download them all.
â JoL
Jan 14 at 5:11
 |Â
show 1 more comment
up vote
8
down vote
accepted
As wget
accepts several URLs at once this can be done using brace expansion in bash
:
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh,nixta.sh
(or even
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj,nixta.sh
but this only works for well-suited names of course).
Thanks, allow me to ask, off label - would you consider this a best practice or something commonly done by professional Bash programmers? (at least, the first option which should be with less confusing).
â Arcticooling
Jan 13 at 20:00
1
@Arcticooling Hmm, good question. For URLs it may not make a lot of sense because it prevents easy copy/paste in case you need to access the same file in the browser, I probably wouldn't use it at least. wiki.bash-hackers.org/syntax/expansion/brace says "it's used to generate mass-arguments for a command, that follow a specific naming-scheme.", linuxg.net/⦠has some good examples, I use thecp /path/to/file,.bak
thing regularly (but mostly interactively, not in scripts).
â nohillside
Jan 13 at 20:07
"this only works for well-suited names" â What names do you think it would not work for?
â Hauke Laging
Jan 13 at 20:24
1
@HaukeLaging the second option, which uses brace expansion only for part of the file name, requires file names ending in a common part.
â nohillside
Jan 13 at 21:19
@patrix It makes a lot of sense for URLs; very useful. Oftentimes, a gallery of images on a webpage will have the different image urls differ only by a consecutive number, and so you can dowget http://example.com/img-1..70.jpg
or similar to download them all.
â JoL
Jan 14 at 5:11
 |Â
show 1 more comment
up vote
8
down vote
accepted
up vote
8
down vote
accepted
As wget
accepts several URLs at once this can be done using brace expansion in bash
:
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh,nixta.sh
(or even
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj,nixta.sh
but this only works for well-suited names of course).
As wget
accepts several URLs at once this can be done using brace expansion in bash
:
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh,nixta.sh
(or even
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj,nixta.sh
but this only works for well-suited names of course).
answered Jan 13 at 19:57
nohillside
1,868616
1,868616
Thanks, allow me to ask, off label - would you consider this a best practice or something commonly done by professional Bash programmers? (at least, the first option which should be with less confusing).
â Arcticooling
Jan 13 at 20:00
1
@Arcticooling Hmm, good question. For URLs it may not make a lot of sense because it prevents easy copy/paste in case you need to access the same file in the browser, I probably wouldn't use it at least. wiki.bash-hackers.org/syntax/expansion/brace says "it's used to generate mass-arguments for a command, that follow a specific naming-scheme.", linuxg.net/⦠has some good examples, I use thecp /path/to/file,.bak
thing regularly (but mostly interactively, not in scripts).
â nohillside
Jan 13 at 20:07
"this only works for well-suited names" â What names do you think it would not work for?
â Hauke Laging
Jan 13 at 20:24
1
@HaukeLaging the second option, which uses brace expansion only for part of the file name, requires file names ending in a common part.
â nohillside
Jan 13 at 21:19
@patrix It makes a lot of sense for URLs; very useful. Oftentimes, a gallery of images on a webpage will have the different image urls differ only by a consecutive number, and so you can dowget http://example.com/img-1..70.jpg
or similar to download them all.
â JoL
Jan 14 at 5:11
 |Â
show 1 more comment
Thanks, allow me to ask, off label - would you consider this a best practice or something commonly done by professional Bash programmers? (at least, the first option which should be with less confusing).
â Arcticooling
Jan 13 at 20:00
1
@Arcticooling Hmm, good question. For URLs it may not make a lot of sense because it prevents easy copy/paste in case you need to access the same file in the browser, I probably wouldn't use it at least. wiki.bash-hackers.org/syntax/expansion/brace says "it's used to generate mass-arguments for a command, that follow a specific naming-scheme.", linuxg.net/⦠has some good examples, I use thecp /path/to/file,.bak
thing regularly (but mostly interactively, not in scripts).
â nohillside
Jan 13 at 20:07
"this only works for well-suited names" â What names do you think it would not work for?
â Hauke Laging
Jan 13 at 20:24
1
@HaukeLaging the second option, which uses brace expansion only for part of the file name, requires file names ending in a common part.
â nohillside
Jan 13 at 21:19
@patrix It makes a lot of sense for URLs; very useful. Oftentimes, a gallery of images on a webpage will have the different image urls differ only by a consecutive number, and so you can dowget http://example.com/img-1..70.jpg
or similar to download them all.
â JoL
Jan 14 at 5:11
Thanks, allow me to ask, off label - would you consider this a best practice or something commonly done by professional Bash programmers? (at least, the first option which should be with less confusing).
â Arcticooling
Jan 13 at 20:00
Thanks, allow me to ask, off label - would you consider this a best practice or something commonly done by professional Bash programmers? (at least, the first option which should be with less confusing).
â Arcticooling
Jan 13 at 20:00
1
1
@Arcticooling Hmm, good question. For URLs it may not make a lot of sense because it prevents easy copy/paste in case you need to access the same file in the browser, I probably wouldn't use it at least. wiki.bash-hackers.org/syntax/expansion/brace says "it's used to generate mass-arguments for a command, that follow a specific naming-scheme.", linuxg.net/⦠has some good examples, I use the
cp /path/to/file,.bak
thing regularly (but mostly interactively, not in scripts).â nohillside
Jan 13 at 20:07
@Arcticooling Hmm, good question. For URLs it may not make a lot of sense because it prevents easy copy/paste in case you need to access the same file in the browser, I probably wouldn't use it at least. wiki.bash-hackers.org/syntax/expansion/brace says "it's used to generate mass-arguments for a command, that follow a specific naming-scheme.", linuxg.net/⦠has some good examples, I use the
cp /path/to/file,.bak
thing regularly (but mostly interactively, not in scripts).â nohillside
Jan 13 at 20:07
"this only works for well-suited names" â What names do you think it would not work for?
â Hauke Laging
Jan 13 at 20:24
"this only works for well-suited names" â What names do you think it would not work for?
â Hauke Laging
Jan 13 at 20:24
1
1
@HaukeLaging the second option, which uses brace expansion only for part of the file name, requires file names ending in a common part.
â nohillside
Jan 13 at 21:19
@HaukeLaging the second option, which uses brace expansion only for part of the file name, requires file names ending in a common part.
â nohillside
Jan 13 at 21:19
@patrix It makes a lot of sense for URLs; very useful. Oftentimes, a gallery of images on a webpage will have the different image urls differ only by a consecutive number, and so you can do
wget http://example.com/img-1..70.jpg
or similar to download them all.â JoL
Jan 14 at 5:11
@patrix It makes a lot of sense for URLs; very useful. Oftentimes, a gallery of images on a webpage will have the different image urls differ only by a consecutive number, and so you can do
wget http://example.com/img-1..70.jpg
or similar to download them all.â JoL
Jan 14 at 5:11
 |Â
show 1 more comment
up vote
0
down vote
I have done this by using awk command and for loop. Let me know for any doubts and confusion
Created one file example.txt by putting below content in a file
cat example.txt
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/
I have assigned papj.sh nixta.sh to the variable i
Used below script to execute as per your requirement
for i in papj.sh nixta.sh; do awk -v i="$i" 'print $0i' example.txt; done
Output
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/nixta.sh
add a comment |Â
up vote
0
down vote
I have done this by using awk command and for loop. Let me know for any doubts and confusion
Created one file example.txt by putting below content in a file
cat example.txt
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/
I have assigned papj.sh nixta.sh to the variable i
Used below script to execute as per your requirement
for i in papj.sh nixta.sh; do awk -v i="$i" 'print $0i' example.txt; done
Output
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/nixta.sh
add a comment |Â
up vote
0
down vote
up vote
0
down vote
I have done this by using awk command and for loop. Let me know for any doubts and confusion
Created one file example.txt by putting below content in a file
cat example.txt
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/
I have assigned papj.sh nixta.sh to the variable i
Used below script to execute as per your requirement
for i in papj.sh nixta.sh; do awk -v i="$i" 'print $0i' example.txt; done
Output
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/nixta.sh
I have done this by using awk command and for loop. Let me know for any doubts and confusion
Created one file example.txt by putting below content in a file
cat example.txt
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/
I have assigned papj.sh nixta.sh to the variable i
Used below script to execute as per your requirement
for i in papj.sh nixta.sh; do awk -v i="$i" 'print $0i' example.txt; done
Output
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/papj.sh
wget -P ~/ https://raw.githubusercontent.com/user/repo/branch/nixta.sh
answered Jan 14 at 12:20
Praveen Kumar BS
1,010128
1,010128
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%2f416896%2funiting-urls-for-a-download-utility-like-wget-in-one-line%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