検索コマンドの結果を変数に入れたいのですが、コマンド置換ブロック内の変数に問題があります。以下の短い例:
#!/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
どうしたの?
検索コマンドの結果を変数に入れたいのですが、コマンド置換ブロック内の変数に問題があります。以下の短い例:
#!/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
どうしたの?