大致介紹Ubuntu declare使用問題
經(jīng)過長時間學習Ubuntu于是和大家分享一下,看完Ubuntu declare使用問題你肯定有不少收獲,希望本文能教會你更多東西。在shell的執(zhí)行上用戶root和普通用戶是不一樣的。使用vi /etc/passwd我們就可以看到在用戶的最后一行也就是定義shell執(zhí)行位置的地方root的位置是/bin/bash 而其他的用戶都是/bin/sh
所以在Ubuntu中root執(zhí)行scipt的時候應該是bash test.sh(注意在linux中是沒有文件后綴名的加上只是為了識別特殊的文件。文件能不能執(zhí)行主要是看文件屬性里面的x是否北打開)而不是sh test.sh。
#!/bin/bash
declare -i number2=10+100+1000
echo "Your result is $number1"
...:~$ sh test03-declare.sh
test03-declare.sh: 5: declare: not found
...:~$ bash test03-declare.sh
...:~$ Your result is 1110
Ubuntu declare的問題介紹完了。
【編輯推薦】