当前位置:首页 > 虚拟机 > 正文

虚拟机脚本怎么写


一、在虚拟机下编写三个shell脚本

1

#!/bin/bash
[$#-ne1]&&echo"用法:$0文件名"&&exit-1
read-p"entercount:"count
i=1
while[$i-le$count]
do
date=`date-d"$i天"+"%Y%m%d"`
$1_${date}
i=$(($i+1))
完成

2

#!/bin/bash
if[$#-ne1];然后
echo"usage:$0file1"
exit-1
fi
if[-e$1];then
now=`date+"%Y%m%d%H%M%S"`
 mv$1$1_${现在}
fi
awk-F':''{print$1}'/etc/passwd|.grept>$1

3.确认和的格式是否正确?

:

user:passwd:UID:GID::/home/user:/bin/bash

:

user:newpasswd

#!/bin/bash
if[$#-ne2];then
echo"usage:$0user_filepasswd_file"
exit-1
fi
read-p"inputaction[add/del]:"act
case$actin
"add")
新用户$1
猫$2|.chpasswd
 ;;
 "del")
                                           
 
      完成
    ;;
   *)echo"错误标志";;
esac