Skip to main content
Became Hot Network Question
add one description about why I use bash glob instead of find command
Source Link

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?

The problem is as follows:

$ 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?

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?

add the test for sameness.
Source Link

The problem is as follows:

$ 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 both containhave 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?

The problem is as follows:

$ 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 both contain "\n" (I didn't check character by character. But at a glance they are same).

Why does the variable assignment not create one object still work for grep?

The problem is as follows:

$ 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?

fix the command used in zsh to be compatible with bash
Source Link

The problem is as follows:

$ FILES=(foo/**/*.suffix bar/**/*.suffix2)
$ grep baz $FILES"${FILES[@]}" # works
# I use this to create one local var with local in one function
$ SUBFILES=$FILESSUBFILES="${FILES[@]}"
$ grep baz $SUBFILES"${SUBFILES[@]}" # doesn't work

I used od to check them but they are same at least both contain "\n" (I didn't check character by character. But at a glance they are same).

Why does the variable assignment not create one object still work for grep?

The problem is as follows:

$ 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 both contain "\n" (I didn't check character by character. But at a glance they are same).

Why does the variable assignment not create one object still work for grep?

The problem is as follows:

$ 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 both contain "\n" (I didn't check character by character. But at a glance they are same).

Why does the variable assignment not create one object still work for grep?

Source Link
Loading