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

简单的shell命令

时间:2018-09-27 19:44:59      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:this   mkdir   user   success   his   list   shell命令   please   read   

#! /bin/bash
xzh=“/1/2/3/4”
if [ ! -e $xzh ]
then
mkdir -p $xzh
fi

#!/bin/bash
read -p "please set file:" n
if[ ! -e $n ]
then
touch $n
fi

#!/bin/bash
n=cat iplist
for IP in $n
do
ping -c 3 -i 0.2 -w 3 $IP &> /dev/null
if [ $? -eq 0 ] ; then
echo "Host $IP is on-line."
else
echo "Host $IP is off-line."
fi
done

#!/bin/bash
read -p "please set directory:" n
if [ ! -e $n ]
then
mkdir -p $n
else
echo "this $n directory exist"
fi

read -p "Enter your score (0-100) : " GRADE
if [ $GRADE -ge 85 ] && [ $GRADE -le 100 ] ; then
echo "$GRADE is Excellent"
elif [ $GRADE -ge 70 ] && [ $GRADE -le 84 ] ; then
echo "$GRADE is Pass"
elif [ $GRADE -gt 100 ] || [ $GRADE -lt 0 ] ; then
echo "$GRADE is does not exist"
else
echo "$GRADE is FAil"
fi

#!/bin/bash
read -p " Enter a name : " n
if [ -e $n ] && [ -d $n ] ; then
echo "$n is directory"
elif [ -e $n ] && [ -f $n ] ; then
echo "$n is file"
else
echo "$n is does not exist"
fi

#!/bin/bash
read -p "Enter The Users Password : " n
for u in cat forlist
do
id $u &> /dev/null
if [ $? -eq 0 ]
then
echo "Already exists"
else
useradd $u $> /dev/null
echo "$N" | passwd --stdin $u &> /dev/null
if [ $? -eq 0 ]
then
echo "$u ,Create success"
else
echo "$u ,Create failure"
fi
fi
done

简单的shell命令

标签:this   mkdir   user   success   his   list   shell命令   please   read   

原文地址:http://blog.51cto.com/13956297/2286834

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