0

検索コマンドの結果を変数に入れたいのですが、コマンド置換ブロック内の変数に問題があります。以下の短い例:

#!/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

どうしたの?

4

1 に答える 1

0

試す

pattern="file*"
res=$( find . -maxdepth 1 -type f -name "${pattern}" )
于 2012-10-10T10:34:22.223 に答える