2015年7月2日 星期四

[ubuntu] Shell Script 筆記


function 使用方式
    function Sync() {
        echo "sync $1"
        p4 sync "@$1"
    }
    Sync

時間使用方式
    Date=$(date +%Y%m%d)
    Time=$(date +%H%M%S)


if else 使用方式
    if [ -d "$tar" ]
    then
        echo "$tar found."
    else
        mkdir "$tar"
    fi



[ string1 = string2 ] string1 and string2 are equal
[ string1 != string2 ] string1 and string2 are not equal
[ string1 \< string2 ] string1 is lexically less than string2(e.g. 'a' is less than 'b')
[ string1 \> string2 ] string1 is lexically greater than string2(e.g. 'b' is greater than 'a')
[ -e file ] file exists
[ -f file ] file is a file
[ -d file ] file is a directory
[ n1 -eq n2 ] true if integer n1 = integer n2
[ n1 -ne n2 ] true if integer n1 <> n2
[ n1 -gt n2 ] true if n1 > n2
[ n1 -ge n2 ] true if n1 >= n2
[ n1 -lt n2 ] true if n1 < n2
[ n1 -le n2 ] true if n1 <= n2

沒有留言:

張貼留言