小练习,仅供参考
shell编写
#!/bin/bash
for i in {1..9}
do
for j in {1..9}
do
if [ $j -le $i ] ;then
echo -ne "$j*$i=`echo $(($i * $j))` \t"
fi
done
echo " "
done
awk编写
#!/bin/bash
awk ‘BEGIN{
for(i=1;i<=9;i++)
{
for(j=1;j<=i;j++)
{
k=i*j;
printf (j"*"i"="k" \t");
}
print ("\n")
}
}‘