13
#!/bin/bash

names= find /home/devuser -name 'BI*'
echo $names

for name in {names[@]}
do    
 echo $name
 $var = $var$name   
done

echo $var

closed as unclear what you're asking by bahamat, manatwork, Chris Down, Anthon, Bernhard Dec 17 '13 at 11:23

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    And what is your question? – rzymek Dec 17 '13 at 9:35
16
#!/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
  • 1
    Are 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 9:27
  • Better. :) Now the comment. Then executing and capturing find's output. Then the array variable in the for's in clause. – manatwork Dec 17 '13 at 9:31
  • 1
    The 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 9:41
  • 1
    You forgot a $, the for loop line should read for name in ${names[@]} – bcattle Sep 3 '14 at 5:36
4

Change

$var = $var$name   

to

var=$var$name   

Not the answer you're looking for? Browse other questions tagged or ask your own question.