#!/bin/bash
names= find /home/devuser -name 'BI*'
echo $names
for name in {names[@]}
do
echo $name
$var = $var$name
done
echo $var
Asked
Active
Viewed 9.5k times
21
-
1And what is your question? – rzymek Dec 17 '13 at 09:35
2 Answers
29
#!/bin/bash
names= find /home/devuser -name 'BI*'
echo $names
for name in {names[@]}
do
echo $name
var=$var$name //$ should be removed which is prefixed before var. Blank space before and after equal sign should be removed to run this code.
done
echo $var

Rui F Ribeiro
- 56,709
- 26
- 150
- 232

Ruban Savvy
- 8,659
-
1Are you sure is correct to use sigil in front of the variable name on the left side of an assignment? Anyway, better review your entire post, starting with that comment. – manatwork Dec 17 '13 at 09:27
-
Better. :) Now the comment. Then executing and capturing
find
's output. Then the array variable in thefor
'sin
clause. – manatwork Dec 17 '13 at 09:31 -
1The final point will probably be that is better to use no loop:
var="$(IFS=; echo "${names[*]}")"
. So unless you wish to teach the question owner, there is no much benefit in correcting his multiple syntax errors. – manatwork Dec 17 '13 at 09:41 -
2