I want to put result of find command to variable – and I have a problem with variable inside command substitution block. Bellow short example:
#!/bin/bash
pattern='"file*"'
res=$(find . -maxdepth 1 -type f -name ${pattern}) # doesn't work
#res=$(find . -maxdepth 1 -type f -name "file*") # works
echo $res
What’s wrong?
Try