|
|
|
|
|
by madhadron
3274 days ago
|
|
First, if your bash script grows beyond about ten lines, it's time to consider rewriting it in a cleaner language. Python's a common one. I used to use Haskell for that kind of scripting as well, which was astonishingly good at it. Here's my study suggestion: 0. Learn to use variable interpolation and backticks. 1. if blocks and the [ built-in function. Go read about the grammar and look at the flags that [ takes. Memorize the most common couple (file exists, is a directory), and know how to look up the others when needed. Find examples of variable interpolation tricks needed to make this function. 2. for and while blocks. Learn the grammer. for is mostly useful with `seq ...` or a file glob. 3. Learn some of the options to make bash fail early and loudly like pipefail. 4. Most of the power of bash is in the programs you call, and they aren't always the same ones you use interactively. Other folks have mentioned some of these. find, xargs, wait... |
|