Linux简单脚本编写
发布网友
发布时间:2022-04-23 16:29
我来回答
共2个回答
热心网友
时间:2023-06-09 16:04
灞曞紑鍏ㄩ儴2銆?br />
#!/bin/bash
while read LINE
do
ass="$ass$LINE"
case $LINE in
EOF) exit ;;
esac
echo "$ass"
done
4銆?br />#!/bin/bash
_type1=`file $1 | cut -d" " -f2-`
_type2=`file $2 | cut -d" " -f2-`
_time1=`ls -l $1 | awk '{print $6,$7,$8}'`
_time2=`ls -l $2 | awk '{print $6,$7,$8}'`
test -f $1 && test -f $2 && [ "${_type1}" = "${_type2}" ] && find -perm 644 | grep -E "$1|$2" >/dev/null 2>&1
if [ $? = 0 ];then
if test $1 -nt $2 ; then
cp $1 /tmp && echo "Copy is ok"
fi
if test $2 -nt $1 ; then
cp $2 /tmp && echo "Copy is ok"
fi
if [ "${_time1}" = "${_time2}" ];then
echo "The time of two files is as well."
fi
else
echo "File is different."
fi
热心网友
时间:2023-06-09 16:05
灞曞紑鍏ㄩ儴3銆?br />#!/bin/bash
operator="+ - x / exit"
echo -n "please input two digits:"
read number1 number2
echo number is: $number1 $number2
select i in $operator
do
case $i in
+)result=$(($number1+$number2));
echo "The result is:$result";;
-)result=$(($number1-$number2));
echo "The result is:$result";;
x)result=$(($number1 * $number2));
echo "The result is:$result";;
/)result=$(($number1 / $number2));
echo "The result is:$result";;
exit)
echo "bye";exit;;
esac
done