1.+到n
for i in {1..n}
do
a=$(($a+$i))
done
echo $a
2.
写一个脚本、输入如下效果 0 01 012 0123 01234 012345 0123456 01234567 012345678 0123456789
for((a=0;a<=9;a++))
do
q[$a]=$a
#echo $((q[$a]))
for((b=0;b<=a;b++))
do
echo -e "$((q[$b]))c"
done
echo " "
done
3.输出
0 101 21012 3210123 432101234
···
for((a=0;a<=9;a++))
do
q[$a]=$a
#echo $((q[$a]))
for((b=a;b>0;b--))
do
echo -e "$((q[$b]))c"
done
for((b=0;b<=a;b++))
do
echo -e "$((q[$b]))c"
done
echo " "
done
4.
输出 99 乘法表
for((a=0;a<=9;a++))
do
q[$a]=$a
for((b=1;b<=a;b++))
do
echo -e "----- $((q[$b]))X$((q[$a]))=$(($((q[$a]))*$((q[$b]))))c ----- "
done
echo " "
done
5修改yum
cd /etc/yum.repos.d/
for a in CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo;do
mv $a $a.bak
done
mv ./CentOS-Media.repo.bak ./CentOS-Media.repo
回复yum
cd /etc/yum.repos.d/
for a in CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo;do
mv $a.bak $a
done