String concatenation in Bash script

后端 未结 3 1501
灰色年华
灰色年华 2021-01-23 18:18

I am writing this Bash script:

count=0   
result

for d in `ls -1 $IMAGE_DIR | egrep \"jpg$\"`
do

    if (( (count % 4) == 0 )); then
                result=\"a         


        
3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-23 19:00

    The = operator must always be written without spaces around it:

    result="$result $d"
    

    (Pretty much the most important difference in shell programming to normal programming is that whitespace matters in places where you wouldn't expect it. This is one of them.)

提交回复
热议问题