第一个有点效用的 shell 模板

2093阅读 0评论2012-10-11 glinuxi
分类:Python/Ruby



  1. #!/bin/sh
  2. if [ $1 = "--help" ]
  3. then
  4. echo -e "Usage: sudoch MODE[,MODE]... FILE...\n\nFILE must be the Direct path\n\nEach MODE is of the form '[ugoa]*([-+=]([rwxXst]*|[ugo]))+'."
  5. exit
  6. fi
  7. if [ $# -lt 2 ]
  8. then
  9. echo "usge command -authority -path"
  10. exit
  11. fi
  12. File="$2"
  13. authority="$1"
  14. all="$@"
  15. echo $File | grep -q '^/' || File=$PWD/$File
  16. dir="/usr/local/ /usr/local/oiweb_qpay/cgi-bin /usr/local/ /data/sales_svr/"
  17. for LINE in `echo $dir`
  18. do
  19. COUNT_CHAR=`echo "$LINE" | wc -c`
  20. Substr="${File:0:$COUNT_CHAR-1}"
  21. if [ "$Substr" = "$LINE" ]
  22. then
  23. flag="0"
  24. chmod -R $all
  25. break
  26. fi
  27. done
  28. if [ "$flag" != "0" ]
  29. then
  30. echo "error: the path is not allowed to use the command"
  31. fi
"/data/evegao/../"| sed 's/\/[^\/]*\/\.\.//g'
上一篇:C++ 文件读取一行
下一篇:二重循环的另一种表示方法。