One correction at 39:41 ${#array} does not expand to the length of the array. It expands to the length of ${array[0]}, which also happens to be 3 in this case. For the array length you have to use ${#array[*]} or ${#array[@]}
In brace expansion, what is the point of the "commas" at the start of the pattern? It was never explained I don't think. The example slide (49:38) also doesn't use commas at the start but the actual examples (49:51) all have commas in front of the patterns.
I'm sure you have worked it out by now, but just in case someone else has the same question: these commas separate variants of expansion and if nothing precedes (or follows) the comma it defines an empty pattern so the prefix/suffix is used as it is (expanded with nothing) in the resulting string. [52:02] man{,} whitch turns into "man man" is a fun example. In the example you mentioned [49:51] w/o comma at the start the first entry of an unchanged word "bash" would've been missing. At [51:03] there wouldn't have been an initial file name w/o this comma.
Not really, the redirection is setup by bash and failing even before `echo` is called. You can use a random command which doesn't even exists to get the same error: $ unknown > /dev/full -bash: /dev/full: Operation not permitted But since as a builtin echo is part of bash the distinction is very subtle.
Great stuff yet again, thankyou! at 1:14:30, did anyone catch the the command for expanding the variable "$fielname" on the command line - CTRL- ___ something. I can't hear it clearly enough, thanks in advance : )
Ctrl-Alt-e will perform expansion on the current command line, including alias, history, and shell word expansion (including command substitution and arithmetic expansion, though not arithmetic evaluation which is not part of an expansion). It won't perform brace expansion, unless, of course, it is nested inside a command substitution, which will be executed in its entirety. This should pull up the relevant section of the man page: man -P "less +/shell-expand-line" bash This will show the current binding in your shell for the shell-expand-line function (it is unlikely this has been assigned a different binding, but this command would tell you if so): bind -q shell-expand-line
Hi James, many thanks for this extra info, it's revealed a tressure-trove of cl goodness. Turns out on my set-up it's \e\C-e (raspberry pi, stretch lite, bash 4.4) - interesting 'cos for years I've been using \e\S-u to uppercase strings, I thought it was a one-off, but it seems there are dozens of these commands. Thanks for all the great content you've put out. Your pdfs are a invaluable reference.
While using printf and a while loop might be more verbose compared to simpler methods like cat for basic file writing, it offers more flexibility and control over the content being written into the file