Thank you for the reply! Guess a guide on arrays would also be super useful - the example you made right here was more clarifying than many web articles I have read...
Would you believe me if I told you that I've never, ever, used getopts or paralllel ? 🙈 I Never had the need to ... I found better alternatives that were easier to "memorize".
getopts - See bargs; A framework for creating a Bash CLI. You would expect me to use getops for the "Usage" menu ... But I haven't, I used other tricks to make it work
parallel - I've never processed big files in Bash, if I need to go down this road, I'll probably use Go, where it's more inclined towards parallelism and threading. I do use background jobs, but mainly for short processes which don't require "blocks of data". Instead, I use background jobs, which is simply adding & to a command and wait in the bottom of the file to wait for it to finish. For example "downloading 5 files in parallel" or "encrypting 10 files in parallel".
curl -o file1 https://example.com/file1 &
curl -o file2 https://example.com/file2 &
curl -o file3 https://example.com/file3 &
curl -o file4 https://example.com/file4 &
curl -o file5 https://example.com/file5 &
wait# for all jobs to finish ...
It's also a matter of time/knowledge; if you know getopts and parallel then use them. If you don't, feel free to pass it, as I haven't found it "mandatory", but that's me.
The way I name it
Output
I usually name my iterator as
item
, even if it's aLIST_OF_ROWS
orARRAY_OF_THINGS
I usually pickitem
as my iterator (in any lang).So, as you can see, there's no clear preference, just go with what suits you, and if you find
item
to be good for you, go for itThank you for the reply! Guess a guide on arrays would also be super useful - the example you made right here was more clarifying than many web articles I have read...
I'll definitely cover arrays in my next blog post, thank you for the feedback, much appreciated!
Also, off the top of my mind: getopt for flags and parallel to avoid writing loops in scripts (I’m just being creative)
Would you believe me if I told you that I've never, ever, used
getopts
orparalllel
? 🙈 I Never had the need to ... I found better alternatives that were easier to "memorize".getopts - See bargs; A framework for creating a Bash CLI. You would expect me to use
getops
for the "Usage" menu ... But I haven't, I used other tricks to make it workparallel - I've never processed big files in Bash, if I need to go down this road, I'll probably use Go, where it's more inclined towards parallelism and threading. I do use
background jobs
, but mainly for short processes which don't require "blocks of data". Instead, I usebackground jobs
, which is simply adding&
to a command andwait
in the bottom of the file to wait for it to finish. For example "downloading 5 files in parallel" or "encrypting 10 files in parallel".It's also a matter of time/knowledge; if you know
getopts
andparallel
then use them. If you don't, feel free to pass it, as I haven't found it "mandatory", but that's me.I didn’t know about bargs! That’s precious advice, thank you!