shell

shell1.sh

#!/bin/bash
#shell5

if test -w $1
   then echo "writeable"
else
   echo "unwriteable"
fi


if test -r $1
  then echo "readable"
else
  echo "unreadable"
fi


if test -x $1
   then echo "excuteable"
else
   echo "unexcuteable"
fi

 

 

usb.sh

#!/bin/bash
#usb

echo "Welcome to use AUTOUSB"
echo "do you want to load the usb(y/n)"

read ANSWER

if [ $ANSWER = Y -o $ANSWER =y]
  then mount -t vfat/dev/sdal/mnt/usb
  echo "do you want copy the file to /home/limao/dazhi(y/n)"
  read ANSWER
  while [ $ANSWER=y -o $ANSWER=Y ]
  do
    ls -a /mnt/usb
    echo "type the filename you want to copy"
    read FILE
    cp $FILE /home/limao/dazhi
    if [ $? = 0]
    then
       echo "copy finish"
    else
       echo "copy errored"
    fi
    echo "any another files(y/n)"
    read ANSWER
  done
fi

echo "do you want to copy the file to usb(y/n)"
read ANSWER
while [ $ANSWER=y -o $ANSWER=y]
do
  ls -a /home/limao/dazhi
  echo "type the filename want to copy to usb "
  read FILE
  cp "/home/limao/dazhi" /mnt/usb
  if [ $? = 0]
  then
     echo "copy file finished"
  else
     echo "copy file errored"
  fi
  echo "any otherfiles(y/n)"
  read ANSWER
done


echo "do you want to umount usb (y/n)"
read ANSWER
if [ $ANSWER=y -o $ANSWER=Y ]
then
   umount /mnt/usb
else
   echo "Haven't umount!"
fi

echo "Goodbye"

 

shell2.sh

#!/bin/bash
#shell8

for i in 1 2 3 4 5 6 7 8 9
do
   for j in 1 2 3 4 5 6 7 8 9
   do
     if test $i -ge $j
     then
        echo -e "$j * $i = \c"
 echo -e  "$[ $j*$i ]\c"
 echo -e  "\t\c"
     fi
    done
    echo  ""
done

 

shell3.sh

#!/bin/bash
#shell9

sum=0
count=0

until [ $count -gt 100 ]
do
  sum=$[$sum+$count]
  count=$[$count+1]
done
echo "count $count"
echo "sum $sum"

 

 

signal.sh

#!/bin/sh

trap 'rm -f ./my_temp_$$' INT
echo creating file ./my_temp_$$
date > ./my_temp_$$


echo "press interrupt to interrupt ..."
while [ -f ./my_temp_$$ ] ; do
    echo FILE EXIS
    sleep 1
done


trap INT
echo creating...
date > ./my_temp_$$

echo "press the interrupt..."
while [ -f ./my_temp_$$ ] ;do
   echo EXIT
   sleep 1
done

echo we wewewe

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值