[sh]md5sum接变量,find排除,sh判断文件存在

1.md5sum
md5sum `cat path_to_file|dos2unix`
注: 发现有些linux是gbk编码, 导致md5或ls 接变量后报错.需要dos2unix处理


2.find排除文件
find /home/game_*/conf/  -type f ! -name "*SOPPEX*" ! -name "*bak*" -maxdepth 1|xargs md5sum >> /tmp/res.txt

3.sh判断文件存在后执行
if ls dll/test.txt 1> /dev/null 2>&1; then
    ls -l dll/test.txt|awk '{print $9,$10,$11}' >> /tmp/res2.txt
else
    echo "err: test.txt <span style='color: red; background-color:yellow; font-weight: bold'>not found</span>" >> /tmp/res2.txt
fi


posted @ 2018-08-10 09:47  mmaotai  阅读(209)  评论(0编辑  收藏  举报