我只是尝试了一个简单的基于菜单的 shell 脚本来获取我系统的公共 ip。使用 ( curl ifconfig.me ) .. 但我发现它的行为有所不同。
在这里我试过:
anupam@JAZZ:~/Desktop$ cat menuui
#
# Script to create simple menus and take action according to that selection
# menu item
#
while :
do
clear
echo "___________________________________"
echo "Main Menu"
echo "___________________________________"
echo "[1] Show Today's date/time"
echo "[2] Show files in current directory"
echo "[3] Show calendar"
echo "[4] Start a calculator"
echo "[5] Start editor to write letters"
echo "[6] Show your public ip"
echo "[7] Exit/Stop"
echo "===================================="
echo -n "Enter your menu choice[1-5]:"
read yourch
case $yourch in
1) echo "Today is `date` ,press a key..." ; read ;;
2) echo "Files in `pwd` "; ls -l;echo "Press a key..."; read;;
3) cal; echo "Press a key..." ; read ;;
4) bc;;
5) vi;;
6) echo "Your public ip is `curl ifconfig.me`";;
7) exit 0 ;;
*) echo "Opps!!! Please select choices 1,2,3,4 or 5";
echo "Press a key...";read;;
esac
done
然后我执行了它...
这不是我期望的..我怎么能解决这个问题?
curl
与-s
选项一起使用。从man curl
它不会显示进度表或错误消息等其他详细信息。修改后的语句看起来像,
$()
比命令替换引用更好用``