今天一哥們找我杨伙,幫他寫下面的作業(yè)交差,問題其實很簡單萌腿,不知道他是怎么學(xué)的限匣,特此記錄下。
作業(yè)內(nèi)容:
1毁菱、編寫腳本輸入一組數(shù)字
2膛腐、判斷是否為數(shù)字,如果不是或者為空鼎俘,提示重新輸入。
3辩涝、如果為數(shù)字則打倒序轉(zhuǎn)后的數(shù)字
如果有看到對你有幫助贸伐,麻煩給個關(guān)注,我會持續(xù)更新工作中的小技巧和只是沉淀怔揩,謝謝捉邢。不廢話了,馬上附上腳本商膊。
#!bin/bash
while :
do
read -p "Please enter the number:" number
if [ "$number" ] & [ "$number" -gt 0 ] 2>/dev/null ;then
new_num=$(echo "$number"|rev)
echo "$new_num"
else
echo "Error,Please enter the number!"
fi
done