字符串重复

基本类型 / 字符串

#printf repeats its format for every argument,
#%.0s prints the argument with zero length, that is nothing
strV=$(printf '7%.0s' {1..3})
#strV is "777"

#{1..$count} does not work: the braces go before the variables,
#so the arguments come from seq (unquoted, to give three words)
count=3
laugh=$(printf 'ha%.0s' $(seq "$count"))
#laugh is "hahaha"

echo "strV is $strV"
echo "laugh is $laugh"