bash - Wildcard single file -
given following files
$ ls bar.txt baz.txt qux.txt i save first txt file variable. tried this
$ var=*.txt but saves files
$ echo $var bar.txt baz.txt qux.txt i using wildcard if possible, , extglob okay. files here not have spaces in name solution work files spaces.
after using kamituel’s answer realized can work too
$ set *.txt $ echo $1 bar.txt
use this:
$ var=(*.txt) $ echo $var bar.txt key here use parentheses - putting elements array. echo $var prints first element array (bar.txt). can see printing whole array:
$ echo ${var[@]} bar.txt baz.txt qux.txt
Comments
Post a Comment