variable-expansion
Brace expansion with variable? [duplicate]
Workarounds for not being able to use variables in a sequence brace expression: If the intent is merely to iterate over numbers in a range – as in the OP’s case – the best choice is not to use brace expansion, but instead use bash’s C-style loop – see user000001’s answer. If the specific numbers … Read more
How do SETLOCAL and ENABLEDELAYEDEXPANSION work?
I think you should understand what delayed expansion is. The existing answers don’t explain it (sufficiently) IMHO. Typing SET /? explains the thing reasonably well: Delayed environment variable expansion is useful for getting around the limitations of the current expansion which happens when a line of text is read, not when it is executed. The … Read more
How to obtain the first letter in a Bash variable?
word=”tiger” firstletter=${word:0:1}
What is the most elegant way to remove a path from the $PATH variable in Bash?
My dirty hack: echo ${PATH} > t1 vi t1 export PATH=$(cat t1)
How does the Windows Command Interpreter (CMD.EXE) parse scripts?
We performed experiments to investigate the grammar of batch scripts. We also investigated differences between batch and command line mode. Batch Line Parser: Here is a brief overview of phases in the batch file line parser: Phase 0) Read Line: Phase 1) Percent Expansion: Phase 2) Process special characters, tokenize, and build a cached command … Read more
When do we need curly braces around shell variables?
In this particular example, it makes no difference. However, the {} in ${} are useful if you want to expand the variable foo in the string “${foo}bar” since “$foobar” would instead expand the variable identified by foobar. Curly braces are also unconditionally required when: expanding array elements, as in ${array[42]} using parameter expansion operations, as … Read more