Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1077279
  • 博文数量: 120
  • 博客积分: 887
  • 博客等级: 准尉
  • 技术积分: 1883
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-05 21:10
个人简介

RHCE,CCNA,熟悉shell脚本

文章分类

全部博文(120)

文章存档

2015年(16)

2014年(20)

2013年(48)

2012年(20)

2011年(16)

分类: Python/Ruby

2011-08-02 18:50:53

#! /bin/bash
#written by lengxuezhixuan
#chmod;chown the directory from file
filedir=/root
filename=$filedir/list.txt
sed -i 's#\\#/#g' $filename
sed -i 's#^\^/#/s#g' $filename
sed -i 's#^//#/#' $filename
sed -i 's#/$##g' $filename
sed -i 's#\ $##g' $filename
if [ $(whoami) != root ]
then
        echo "please change to root to execute this program"
else
        if [ $(pwd) != $filedir ]
        then
                echo "this path is not $filedir!"
                sleep 2
                cd $filedir
                while read hang
                do
                        chown root:root $hang -R
                        chmod 755 $hang -R
                done < $filename
        else
                echo "this path is $filedir!"
                sleep 2
                cd $filedir
                while read hang
                do
                        chown root:root $hang -R
                        chmod 755 $hang -R
                done < $filename
        fi
fi
阅读(1131) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~