Sample Header Ad - 728x90

variable assignment doesn't create one same object at least for grep

0 votes
2 answers
136 views
The problem is as follows (Here I don't use find since it doesn't support double-asterisk wildcard **):
$ FILES=(foo/**/*.suffix bar/**/*.suffix2)
$ grep baz "${FILES[@]}" # works
# I use this to create one local var with local in one function
$ SUBFILES="${FILES[@]}"
$ grep baz "${SUBFILES[@]}" # doesn't work
I used od to check them but they are same at least have the same number of "\n" and the same length (I didn't check character by character. But at a glance they are same).
$ echo ${SUBFILES[@]} | od -c
$ echo ${FILES[@]} | od -c
Why does the variable assignment not create one object still work for grep?
Asked by An5Drama (173 rep)
Jan 2, 2025, 08:43 AM
Last activity: Jan 2, 2025, 06:52 PM