So, Let's say I have the following pattern:
in a file called
And I want to match the exact string above but for whatever reason, I choose to loop over some numbers from a list, use those as variable and try to do this:
Where the above
$varhere is equal to the number above, being
1. (while i mentioned looping over number, this was just a future possible use cases for this and remain an example)
Now to make things easier, say I want to match the above exact pattern while using the above variable and it's content:
grep 'Thisisatest="$varhere"' file
Where file contain the string
$varhere contain the number
Problem being, this wouldn't work because variable expansion doesn't occur when in-between single quotes (like above).
Here the failed attempt at countering this:
- substitution of content from variable substitution
Here I use
echo to see if it output the right string so it can be used as input for grep...it output this instead:
- Add more quotes
The rest is obvious... Now the very last attempt above seems to be close to what i want, but still not it.
Any way(s) to do the above?