for j in * .* ; do
cp $j ../$name-S$i.gid/${j%%. * }$i.${j#*.}
done
Could someone tell me what this for loop does? What do *, % and # mean?
($name is a path of a directory in which there are -S1.gid ... -Sn.gid directory)
for j in * .* ; do
cp $j ../$name-S$i.gid/${j%%. * }$i.${j#*.}
done
Could someone tell me what this for loop does? What do *, % and # mean?
($name is a path of a directory in which there are -S1.gid ... -Sn.gid directory)
for foo in bar; do something; done) over the files matching the * and .* globs and
cp)
$j) to../)$name, -S, $i).gid/,${j...}) the longest string (%%) matching the glob . *, meaning
$i,${j...}) the shortest string matching the glob *., meaning
All this is explained in man bash. This code should be simplified to use quoted variables for each of those expansions to explain what they are. It's not maintainable as is IMO.