每天一道编程题

1. 用Shell编程,判断一文件是不是块或字符设备文件,如果是将其拷贝到/dev目录下。

#!/usr/sh 
read -p "Please input filename:"  file
if [ -b "$file" -o -c "$p" ];then
    echo " $file is a device file" && cp $file /dev/
else
   echo "$file is not a device file" && exit 1
fi

 2. 设计一个shell程序,添加一个新组为class1,然后添加属于这个组的30个用户,用户名的形式为stdxx,其中xx从01到30。

#!/bin/sh
groupadd class1
i=101
while [ $i le 130 ]
do
        usradd -g class1 std$i
done

    本来想第二个写为usradd -g class1 std{01..30}结果发现会自动将一位数前的0去掉。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值