All Questions
Tagged with quoting variable-substitution
24
questions
0
votes
1
answer
3k
views
Searching path as search pattern in grep command
I have saved the path in the variable .
var="/home/myfolder/subfolder"
Need to search whether the path in available in a text file using grep.
grep -l '${var}' * >abc.txt
I'm trying to list ...
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
$ ...
2
votes
2
answers
211
views
variable substitution in CLI and for loops
I am pretty sure this has been asked already in some form, I just cannot come up with a good find to search it.
I want to have a script that do things N times and to which I can pass as a variable ...
3
votes
3
answers
3k
views
Variable expansion in Bash
I tried the following commands
variable='one|name'
echo $variable
The output is
one|name
whereas echo one|name gives an error No command 'name' found. This is reasonable because bash treats | as a ...
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 ...
3
votes
1
answer
3k
views
variable expansion within command substitution over SSH bash 4.X
I want to do this ssh ${w100user}@web100 'ls -l "$(grep "${1}" /etc/pure-ftpd/pureftpd.passwd|cut -d':' -f6)"'
Which obviously performs an ssh session to server web100 as w100user and then greps ...
2
votes
1
answer
5k
views
bash: export: `--wait': not a valid identifier
When I run git-sh from my terminal it works fine. But I get the following warning.
bash: export: `--wait': not a valid identifier
What is this and how do I get rid of it?
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 ...
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 ...