Top "Variable-expansion" questions

Evaluating or expanding a variable to get its value.

How to obtain the first letter in a Bash variable?

I have a Bash variable, $word, which is sometimes a word or sentence, e.g.: word="tiger" Or: word="This …

bash text-processing variable-expansion
How does the Windows Command Interpreter (CMD.EXE) parse scripts?

I ran into ss64.com which provides good help regarding how to write batch scripts that the Windows Command Interpreter …

windows parsing batch-file cmd variable-expansion
What is the most elegant way to remove a path from the $PATH variable in Bash?

Or more generally, how do I remove an item from a colon-separated list in a Bash environment variable? I thought …

bash shell path variable-expansion list-processing
Expand variable inside single quotes

How can I expand $pw inside single quotes? $pw = "$PsHome\powershell.exe" cmd.exe /c 'schtasks /create /tn cleanup /tr "$…

powershell variable-expansion
Performance of variable expansion vs. sprintf in PHP

Regarding performance, is there any difference between doing: $message = "The request $request has $n errors"; and $message = sprintf('The request %…

php string performance printf variable-expansion
Passing a command with arguments as a string to docker run

The issue I'm facing is how to pass a command with arguments to docker run. The problem is that docker …

linux bash shell docker variable-expansion
How to create for-loops with jq in bash

I'm trying to split a json file into various json files. The input (r1.json) looks like : { "results" : [ { content 1 } , { content 2 } , { …

bash for-loop variable-expansion
Brace expansion with variable?

#!/bin/sh for i in {1..5} do echo "Welcome" done Would work, displays Welcome 5 times. #!/bin/sh howmany=`grep -c $1 /root/…

bash variables syntax variable-expansion