linux命令整理

1.) 显示文件夹下各个文件大小(包含目录和文件)

du -hs *

2.) shell校验日期格式有效性

#!/bin/sh

# para
#     $1 date format
#     $2 date value
#     if input bit not enough, result comes to be wrong 
function check_date()
{
    echo "##### " $* " #####"

    if [[ "$2" = `date -d "$2" +"$1"` ]]
    then
        echo "format($1) date($2)" right
        return 0;
    else
        echo "format($1) date($2)" wrong
        return 1;
    fi
}


check_date "$1" "$2"

 

posted @ 2017-01-23 10:13  挨踢淫才  阅读(137)  评论(0编辑  收藏  举报