r/tinycode • • Mar 14 '18

Map is hopefully an improvement upon the ergonomics of tools like xargs, find -exec and shell for-loops

https://github.com/soveran/map#map
34 Upvotes

9 comments sorted by

View all comments

Show parent comment

1

u/IronJoeM Mar 19 '18

This crashes on my machine when giving it 100000 URLs to download.

cat urls | map url 'curl -O $url &'

This is not a problem for gnu paralel:

cat urls | parallel curl -O

1

u/soveran Mar 19 '18 edited Mar 19 '18

Yes, if creating 100k background jobs crashes your computer of course you should try a different approach! For example, you can create batches and wait for a batch to complete before starting the next one. Or you can write a short script in the language of your choice to iterate in batches, or you can just use parallel if downloading hundreds of thousands of files at once is your thing :-)

I wrote about how map compares to parallel in another thread. The summary would be that if you need to run lots of tasks in parallel very often, then it will be very useful. I wouldn't say it is tinycode because it's 8k lines of perl, but I know you are not suggesting it because it is tinycode, but because it is useful for the usecase you described, and I agree.