1.创建一个/tmp/test目录,里面有3个文件。名字分别为111,222,333.写一个脚本,可以每隔3秒钟循环对这3个文件改名。把111改为222,把222改为333,把333改为111。
#!/bin/sh
        name1=/tmp/test/111
        name2=/rmp/test/222
        name3=/tmp/test/333
 
        while :
                do
                  mv -v $name3 tname
                  mv -v $name2 $name3
                  mv -v $name1 $name2
                  mv -v tname $name1
                  
                 
                  sleep 3
                done
 
 
 
2.提取出/usr/share/doc目录下的所有的文件名为index.html的文件。把它们集中放在/tem/index目录中。文件名字按提取顺序更名标记。即:第一个找到的index.html命名为index.html.1,第二个为index.html.2。以此类推
#!/bin/bash
       num=0
       for file in `find /usr/share/doc -name "index.html"`
               do
                       num=$[$num+1]
                       cp $file /tmp/index/index.$num
               done
 
3.写一个脚本报告用户信息,这个脚本只能添加一个参数,此参数为用户名。脚本可以报告系统中是否有此用户。如果有,程序报告:User exist。如果不存在,报告:No this user。
#!/bin/bash
echo "User search system"
echo "Please input the Username"
read -p "Username:" uname
        for i in `cut -d: -f1 /etc/passwd`
                do
                        if  [ $i = $uname ]
                                then
                                        node=0
                                        echo "User exist"
                                        break
                                else
                                        node=1
                                        continue
                        fi
                done
                        if [ $node -eq 1 ]
                                then
                                echo "No this user"
                        fi
 

4.写一个脚本,统计出你系统/dev目录下所有设备文件以及管道文件,套接字文件的总数
#!/bin/bash
        num1=0
        num2=0
        num3=0
                for i in `find /dev -type b `
                    do
                        num1=$[$num1+1]
                    done
                        echo $num1
                for j in `find /dev -type p `
                    do
                        num2=$[$num2+1]
                    done
                        echo $num2
                for k in `find /dev -type s `
                    do
                        num3=$[$num3+1]
                    done
                        echo $num3