Skip to main content
added 1 characters in body; edited tags; edited title
Source Link
tshepang
  • 67.8k
  • 94
  • 228
  • 297

bash: array Array of string expanded to path?

supposeSuppose I have the following initialization of bash array:

my_array=(
    "/usr/bin"
    "/usr/lib/*.so"
)

ifIf I do iteration using  :

for array_item in ${my_array[@]} 
do 
    ... 
done 

thenThen the content of the my_array is expanded containing path to any files with .so extension in /usr/lib/ directories. but I just wanted the array contain two string which is "/usr/bin" and "/usr/lib/*.so".

howHow should I do that?

bash: array of string expanded to path?

suppose I have the following initialization of bash array

my_array=(
    "/usr/bin"
    "/usr/lib/*.so"
)

if I do iteration using  :

for array_item in ${my_array[@]} 
do 
    ... 
done 

then the content of the my_array is expanded containing path to any files with .so extension in /usr/lib/ directories. but I just wanted the array contain two string which is "/usr/bin" and "/usr/lib/*.so".

how should I do that?

Array of string expanded to path?

Suppose I have the following initialization of bash array:

my_array=(
    "/usr/bin"
    "/usr/lib/*.so"
)

If I do iteration using:

for array_item in ${my_array[@]} 
do 
    ... 
done 

Then the content of the my_array is expanded containing path to any files with .so extension in /usr/lib/ directories. but I just wanted the array contain two string which is "/usr/bin" and "/usr/lib/*.so".

How should I do that?

Source Link
uray
  • 4k
  • 11
  • 39
  • 42

bash: array of string expanded to path?

suppose I have the following initialization of bash array

my_array=(
    "/usr/bin"
    "/usr/lib/*.so"
)

if I do iteration using :

for array_item in ${my_array[@]} 
do 
    ... 
done 

then the content of the my_array is expanded containing path to any files with .so extension in /usr/lib/ directories. but I just wanted the array contain two string which is "/usr/bin" and "/usr/lib/*.so".

how should I do that?