Last active
December 1, 2017 01:25
-
-
Save ethagnawl/6af8d01e84aabcb16619b0c6d382b83a to your computer and use it in GitHub Desktop.
dumb xargs demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I've had a rough understanding of xargs for some time (allows you to do | |
_something_ with the output of a previous command), but never understood it | |
well enough to instinctively reach for it while working on the command line. | |
So, I decided I'd put a little demo together in order to learn more about it. | |
The demo is, admittedly, very basic but it was enough to help me get a better | |
understanding of what xargs can do and when you might want to use it. | |
Roughly, the demo does the following: | |
1.) pipe a list of images to xargs | |
2.) construct a URL for each image | |
3.) download files using newly constructed URLs - in parallel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.jpg | |
2.jpg | |
3.jpg | |
4.jpg | |
5.jpg | |
6.jpg | |
7.jpg | |
8.jpg | |
9.jpg | |
10.jpg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# 1.) pipe list of images to xargs | |
# 2.) construct URL for each image | |
# 3.) download files in parallel | |
cat images.txt | xargs -I img -P 0 wget -O img "http://fillmurray.com/222/"img |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment