bash - Passing glob results through to a function discarding all but first file -
i have following function f() { find . -name "$1"} handy shortcut finding file name. if execute find . -name "*.gradle" in terminal get:
./.gradle ./app/build.gradle ./build.gradle ./dependencies.gradle ./settings.gradle ./wearable/build.gradle if execute f *.gradle in terminal get:
./app/build.gradle ./build.gradle ./wearable/build.gradle the first result correct 1 , wanted one. why getting though 'wrong' result when using function though content same? did inject $1 parameter wrongly?
f *.gradle expands glob, replacing *.gradle list of files in current directory, may run following:
$ f one.gradle two.gradle # $1 $2 which runs:
find . -name one.gradle ...passing first file ($1), , ignoring others.
if want pass glob through find:
f '*.gradle'
Comments
Post a Comment