All Questions
Tagged with quoting variable-substitution
6
questions
26
votes
6
answers
125k
views
Is there any way to print value inside variable inside single quote?
Consider I've set variable site and needs to be printed by echo or printf, but If I use single quote to write something and want to use variable then how?
Example:
$ site=unix.stackexchange.com
$ ...
19
votes
2
answers
95k
views
Passing a variable to sed [duplicate]
I cannot not use a shell variable in sed in the $NUMBER form. I have this line in my shell script:
cat shared.txt sed 's/whatever1/$2 ... whatever2/' > shared2.txt
The result in shared2.txt looks ...
2
votes
2
answers
4k
views
Environment variable not expanded inside the command line argument
I have a file user-pid.out2 which has "usernumber" and "process id" as two columns. based on usernumber I want to find corresponding process id. the first two lines below does not show the output ...
9
votes
4
answers
7k
views
Can I reload variable in a watch command?
Part of my job involves some data handling. One of the tasks is to 'flatten' a set of directories (which we'll call Dir for now), and copy them to a new location called DirFlat.
This can take a long ...
8
votes
3
answers
3k
views
How does Bash handle quoting in the string replacement section of parameter expansion?
Is there any consistent logic to it?
some-command "${somevariable//some pattern/'how does this get parsed?'}"
I've posted some conclusions and raw tests below as an "answer" but they're not a full ...
2
votes
2
answers
369
views
What is the right way to quote nested parameter expansions?
When dealing with with nested parameter expansions, which of these is the correct way to quote things?
This one:
var="${var#"${var%%[![:space:]]*}"}"
Or this one:
var="${var#${var%%[![:space:]]*}}"...