码迷,mamicode.com
首页 > 系统相关 > 详细

常用linux shell脚本记录

时间:2015-12-30 21:52:56      阅读:239      评论:0      收藏:0      [点我收藏+]

标签:

遍历目录下所有的文件是目录还是文件

for file in ./*
do
    if test -f $file
    then
        echo $file 是文件
    fi
    if test -d $file
    then
        echo $file 是目录
    fi
done
filelist=`ls ./proto`
echo $filelist
 
for  file in $filelist;do
         #不能有判断if [-f $file ] ,为什么?因为文件是在当前目录的proto目录下,我们filelist输出的是文件列表,没有带路径,-f x.proto x.proto不在当前目录,肯定为false,if永远为假,加上路径才能为true,if [ -f ./proto/$file ];then 这样就可以了。

                #protoc -I=proto --cpp_out=cpp/ proto/ClientGate.proto
                 protoc -I=proto --cpp_out=cpp/ proto/$file
               
        #       protoc -I=proto -olua/$(basename $file .proto).pb  proto/$file

done

~                                                                                                                              
~          
protoc -I=$SRC_DIR --cpp_out=$DST_DIR $SRC_DIR/addressbook.proto


常用linux shell脚本记录

标签:

原文地址:http://www.cnblogs.com/youxin/p/5090054.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!