1

I know "$*" can not generate the parameters array,it will only return a parameters string.but today I use a parameter named list and let list equal "$*", then I use "for" loop structure, but the result is right. why?

#!/bin/bash
# testing $* and "$*"
list="$*"
for i in $list
do
    echo $i >> file$i
done

For instance: ./test 1 2 3 4 Then my directory will have file1 file2 file3 and file4, It turns out the answer is right!

Zhang Tao
  • 23
  • 8

0 Answers0